

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>dcase_framework.datasets &mdash; DCASE2017 Baseline 1.0 documentation</title>
  

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  
  
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  

  
    <link rel="stylesheet" href="../../_static/theme_overrides.css" type="text/css" />
  

  
        <link rel="index" title="Index"
              href="../../genindex.html"/>
        <link rel="search" title="Search" href="../../search.html"/>
    <link rel="top" title="DCASE2017 Baseline 1.0 documentation" href="../../index.html"/>
        <link rel="up" title="Module code" href="../index.html"/> 

  
  <script src="../../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../../index.html" class="icon icon-home"> DCASE2017 Baseline
          

          
            
            <img src="../../_static/dcase2017_baseline.png" class="logo" />
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Baseline system</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../system_description.html">System description</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../system_description.html#mlp-based-system-dcase2017-baseline">MLP based system, DCASE2017 baseline</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../system_description.html#gmm-based-approach">GMM based approach</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../system_description.html#processing-blocks">Processing blocks</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../applications.html">Applications</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../applications.html#task1-acoustic-scene-classification"> Acoustic scene classification</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../applications.html#results">Results</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../applications.html#task2-detection-of-rare-sound-events"> Detection of rare sound events</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../applications.html#id2">Results</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../applications.html#task3-sound-event-detection-in-real-life-audio"> Sound event detection in real life audio</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../applications.html#id3">Results</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../install.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../usage_tutorial.html">Usage</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../usage_tutorial.html#application-arguments">Application arguments</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../usage_tutorial.html#basic-usage">Basic usage</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../parameterization.html">Parameterization</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../parameterization.html#parameter-overwriting">Parameter overwriting</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../parameterization.html#parameter-file">Parameter file</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../parameterization.html#parameter-hash">Parameter hash</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../parameterization.html#parameter-sections">Parameter sections</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#flow">Flow</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#general">General</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#path">Path</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#dataset">Dataset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#feature-extractor">Feature extractor</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#feature-stacker">Feature stacker</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#feature-normalizer">Feature normalizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#feature-aggregator">Feature aggregator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#learner">Learner</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#recognizer">Recognizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#evaluator">Evaluator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../parameterization.html#logging">Logging</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../reproducibility.html">Reproducibility</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../reproducibility.html#blas-libraries">BLAS libraries</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../reproducibility.html#intel-math-kernel">Intel Math Kernel</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../reproducibility.html#running-the-baseline-system">Running the baseline system</a></li>
</ul>
</li>
</ul>
<p class="caption"><span class="caption-text">DCASE Framework</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../framework.html">Introduction</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../framework.html#training-process">Training process</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../framework.html#testing-process">Testing process</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../extending_framework.html">Extending the framework</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../extending_framework.html#adding-datasets">Adding datasets</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../extending_framework.html#adding-features">Adding features</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../extending_framework.html#addinng-learners">Addinng learners</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../extending_framework.html#extending-applicationcore">Extending ApplicationCore</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../application_core.html">Application core</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../application_core.html#acousticsceneclassificationappcore">AcousticSceneClassificationAppCore</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.html">dcase_framework.application_core.AcousticSceneClassificationAppCore</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.show_dataset_list.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.show_dataset_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.show_parameters.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.show_parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.initialize.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.initialize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.feature_extraction.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.feature_extraction</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.feature_normalization.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.feature_normalization</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.system_training.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.system_training</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.system_testing.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.system_testing</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AcousticSceneClassificationAppCore.system_evaluation.html">dcase_framework.application_core.AcousticSceneClassificationAppCore.system_evaluation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../application_core.html#soundeventappcore">SoundEventAppCore</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.html">dcase_framework.application_core.SoundEventAppCore</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.show_dataset_list.html">dcase_framework.application_core.SoundEventAppCore.show_dataset_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.show_parameters.html">dcase_framework.application_core.SoundEventAppCore.show_parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.initialize.html">dcase_framework.application_core.SoundEventAppCore.initialize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.feature_extraction.html">dcase_framework.application_core.SoundEventAppCore.feature_extraction</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.feature_normalization.html">dcase_framework.application_core.SoundEventAppCore.feature_normalization</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.system_training.html">dcase_framework.application_core.SoundEventAppCore.system_training</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.system_testing.html">dcase_framework.application_core.SoundEventAppCore.system_testing</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.SoundEventAppCore.system_evaluation.html">dcase_framework.application_core.SoundEventAppCore.system_evaluation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../application_core.html#binarysoundeventappcore">BinarySoundEventAppCore</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.html">dcase_framework.application_core.BinarySoundEventAppCore</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.show_dataset_list.html">dcase_framework.application_core.BinarySoundEventAppCore.show_dataset_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.show_parameters.html">dcase_framework.application_core.BinarySoundEventAppCore.show_parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.initialize.html">dcase_framework.application_core.BinarySoundEventAppCore.initialize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.feature_extraction.html">dcase_framework.application_core.BinarySoundEventAppCore.feature_extraction</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.feature_normalization.html">dcase_framework.application_core.BinarySoundEventAppCore.feature_normalization</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.system_training.html">dcase_framework.application_core.BinarySoundEventAppCore.system_training</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.system_testing.html">dcase_framework.application_core.BinarySoundEventAppCore.system_testing</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.BinarySoundEventAppCore.system_evaluation.html">dcase_framework.application_core.BinarySoundEventAppCore.system_evaluation</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../application_core.html#appcore-base-class">AppCore &#8211; base class</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.html">dcase_framework.application_core.AppCore</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.show_dataset_list.html">dcase_framework.application_core.AppCore.show_dataset_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.show_parameters.html">dcase_framework.application_core.AppCore.show_parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.initialize.html">dcase_framework.application_core.AppCore.initialize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.feature_extraction.html">dcase_framework.application_core.AppCore.feature_extraction</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.feature_normalization.html">dcase_framework.application_core.AppCore.feature_normalization</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.system_training.html">dcase_framework.application_core.AppCore.system_training</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.system_testing.html">dcase_framework.application_core.AppCore.system_testing</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.application_core.AppCore.system_evaluation.html">dcase_framework.application_core.AppCore.system_evaluation</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../parameters.html">Parameters</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../parameters.html#recipe">Recipe</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../parameters.html#paths-and-parameter-hash">Paths and parameter hash</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../parameters.html#parametercontainer">ParameterContainer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.html">dcase_framework.parameters.ParameterContainer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.load.html">dcase_framework.parameters.ParameterContainer.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.save.html">dcase_framework.parameters.ParameterContainer.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.exists.html">dcase_framework.parameters.ParameterContainer.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.get_path.html">dcase_framework.parameters.ParameterContainer.get_path</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.show.html">dcase_framework.parameters.ParameterContainer.show</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.log.html">dcase_framework.parameters.ParameterContainer.log</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.override.html">dcase_framework.parameters.ParameterContainer.override</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.process.html">dcase_framework.parameters.ParameterContainer.process</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.process_method_parameters.html">dcase_framework.parameters.ParameterContainer.process_method_parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.parameters.ParameterContainer.get_hash.html">dcase_framework.parameters.ParameterContainer.get_hash</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../files.html">Files</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#audiofile">AudioFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.AudioFile.html">dcase_framework.files.AudioFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.AudioFile.load.html">dcase_framework.files.AudioFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.AudioFile.save.html">dcase_framework.files.AudioFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.AudioFile.exists.html">dcase_framework.files.AudioFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.AudioFile.empty.html">dcase_framework.files.AudioFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#parameterfile">ParameterFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ParameterFile.html">dcase_framework.files.ParameterFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ParameterFile.load.html">dcase_framework.files.ParameterFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ParameterFile.save.html">dcase_framework.files.ParameterFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ParameterFile.exists.html">dcase_framework.files.ParameterFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ParameterFile.empty.html">dcase_framework.files.ParameterFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#featurefile">FeatureFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.FeatureFile.html">dcase_framework.files.FeatureFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.FeatureFile.load.html">dcase_framework.files.FeatureFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.FeatureFile.save.html">dcase_framework.files.FeatureFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.FeatureFile.exists.html">dcase_framework.files.FeatureFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.FeatureFile.empty.html">dcase_framework.files.FeatureFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#datafile">DataFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DataFile.html">dcase_framework.files.DataFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DataFile.load.html">dcase_framework.files.DataFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DataFile.save.html">dcase_framework.files.DataFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DataFile.exists.html">dcase_framework.files.DataFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DataFile.empty.html">dcase_framework.files.DataFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#repositoryfile">RepositoryFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.RepositoryFile.html">dcase_framework.files.RepositoryFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.RepositoryFile.load.html">dcase_framework.files.RepositoryFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.RepositoryFile.exists.html">dcase_framework.files.RepositoryFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.RepositoryFile.empty.html">dcase_framework.files.RepositoryFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#textfile">TextFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.TextFile.html">dcase_framework.files.TextFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.TextFile.load.html">dcase_framework.files.TextFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.TextFile.save.html">dcase_framework.files.TextFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.TextFile.exists.html">dcase_framework.files.TextFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.TextFile.empty.html">dcase_framework.files.TextFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#dictfile">DictFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DictFile.html">dcase_framework.files.DictFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DictFile.load.html">dcase_framework.files.DictFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DictFile.save.html">dcase_framework.files.DictFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DictFile.exists.html">dcase_framework.files.DictFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.DictFile.empty.html">dcase_framework.files.DictFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#listfile">ListFile</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ListFile.html">dcase_framework.files.ListFile</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ListFile.load.html">dcase_framework.files.ListFile.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ListFile.save.html">dcase_framework.files.ListFile.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ListFile.exists.html">dcase_framework.files.ListFile.exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.ListFile.empty.html">dcase_framework.files.ListFile.empty</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../files.html#mixins">Mixins</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.files.FileMixin.html">dcase_framework.files.FileMixin</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../datasets.html">Datasets</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../datasets.html#dataset-base-class">Dataset - Base class</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.html">dcase_framework.datasets.Dataset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.initialize.html">dcase_framework.datasets.Dataset.initialize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.show_info.html">dcase_framework.datasets.Dataset.show_info</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.audio_files.html">dcase_framework.datasets.Dataset.audio_files</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.audio_file_count.html">dcase_framework.datasets.Dataset.audio_file_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.meta.html">dcase_framework.datasets.Dataset.meta</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.meta_count.html">dcase_framework.datasets.Dataset.meta_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.error_meta.html">dcase_framework.datasets.Dataset.error_meta</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.error_meta_count.html">dcase_framework.datasets.Dataset.error_meta_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.fold_count.html">dcase_framework.datasets.Dataset.fold_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.scene_labels.html">dcase_framework.datasets.Dataset.scene_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.scene_label_count.html">dcase_framework.datasets.Dataset.scene_label_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.event_labels.html">dcase_framework.datasets.Dataset.event_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.event_label_count.html">dcase_framework.datasets.Dataset.event_label_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.audio_tags.html">dcase_framework.datasets.Dataset.audio_tags</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.audio_tag_count.html">dcase_framework.datasets.Dataset.audio_tag_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.download_packages.html">dcase_framework.datasets.Dataset.download_packages</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.extract.html">dcase_framework.datasets.Dataset.extract</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.train.html">dcase_framework.datasets.Dataset.train</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.test.html">dcase_framework.datasets.Dataset.test</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.eval.html">dcase_framework.datasets.Dataset.eval</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.train_files.html">dcase_framework.datasets.Dataset.train_files</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.test_files.html">dcase_framework.datasets.Dataset.test_files</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.eval_files.html">dcase_framework.datasets.Dataset.eval_files</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.validation_files.html">dcase_framework.datasets.Dataset.validation_files</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.folds.html">dcase_framework.datasets.Dataset.folds</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.file_meta.html">dcase_framework.datasets.Dataset.file_meta</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.file_error_meta.html">dcase_framework.datasets.Dataset.file_error_meta</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.file_error_meta.html">dcase_framework.datasets.Dataset.file_error_meta</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.relative_to_absolute_path.html">dcase_framework.datasets.Dataset.relative_to_absolute_path</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.Dataset.absolute_to_relative.html">dcase_framework.datasets.Dataset.absolute_to_relative</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../datasets.html#acousticscenedataset">AcousticSceneDataset</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.AcousticSceneDataset.html">dcase_framework.datasets.AcousticSceneDataset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTAcousticScenes_2017_DevelopmentSet.html">dcase_framework.datasets.TUTAcousticScenes_2017_DevelopmentSet</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTAcousticScenes_2016_DevelopmentSet.html">dcase_framework.datasets.TUTAcousticScenes_2016_DevelopmentSet</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTAcousticScenes_2016_EvaluationSet.html">dcase_framework.datasets.TUTAcousticScenes_2016_EvaluationSet</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../datasets.html#soundeventdataset">SoundEventDataset</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.SoundEventDataset.html">dcase_framework.datasets.SoundEventDataset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.SoundEventDataset.event_label_count.html">dcase_framework.datasets.SoundEventDataset.event_label_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.SoundEventDataset.event_labels.html">dcase_framework.datasets.SoundEventDataset.event_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.SoundEventDataset.train.html">dcase_framework.datasets.SoundEventDataset.train</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.SoundEventDataset.test.html">dcase_framework.datasets.SoundEventDataset.test</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTRareSoundEvents_2017_DevelopmentSet.html">dcase_framework.datasets.TUTRareSoundEvents_2017_DevelopmentSet</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTSoundEvents_2017_DevelopmentSet.html">dcase_framework.datasets.TUTSoundEvents_2017_DevelopmentSet</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTSoundEvents_2016_DevelopmentSet.html">dcase_framework.datasets.TUTSoundEvents_2016_DevelopmentSet</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.TUTSoundEvents_2016_EvaluationSet.html">dcase_framework.datasets.TUTSoundEvents_2016_EvaluationSet</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../datasets.html#audiotaggingdataset">AudioTaggingDataset</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.datasets.AudioTaggingDataset.html">dcase_framework.datasets.AudioTaggingDataset</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../metadata.html">Meta data</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../metadata.html#metadataitem">MetaDataItem</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.html">dcase_framework.metadata.MetaDataItem</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.id.html">dcase_framework.metadata.MetaDataItem.id</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.file.html">dcase_framework.metadata.MetaDataItem.file</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.scene_label.html">dcase_framework.metadata.MetaDataItem.scene_label</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.event_label.html">dcase_framework.metadata.MetaDataItem.event_label</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.event_onset.html">dcase_framework.metadata.MetaDataItem.event_onset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.event_offset.html">dcase_framework.metadata.MetaDataItem.event_offset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.identifier.html">dcase_framework.metadata.MetaDataItem.identifier</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataItem.source_label.html">dcase_framework.metadata.MetaDataItem.source_label</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../metadata.html#metadatacontainer">MetaDataContainer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.html">dcase_framework.metadata.MetaDataContainer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.log.html">dcase_framework.metadata.MetaDataContainer.log</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.show.html">dcase_framework.metadata.MetaDataContainer.show</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.get_string.html">dcase_framework.metadata.MetaDataContainer.get_string</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.update.html">dcase_framework.metadata.MetaDataContainer.update</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.filter.html">dcase_framework.metadata.MetaDataContainer.filter</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.filter_time_segment.html">dcase_framework.metadata.MetaDataContainer.filter_time_segment</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.process_events.html">dcase_framework.metadata.MetaDataContainer.process_events</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.remove_field.html">dcase_framework.metadata.MetaDataContainer.remove_field</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.slice_field.html">dcase_framework.metadata.MetaDataContainer.slice_field</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.filter_time_segment.html">dcase_framework.metadata.MetaDataContainer.filter_time_segment</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.add_time_offset.html">dcase_framework.metadata.MetaDataContainer.add_time_offset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.file_list.html">dcase_framework.metadata.MetaDataContainer.file_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.event_count.html">dcase_framework.metadata.MetaDataContainer.event_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.scene_label_count.html">dcase_framework.metadata.MetaDataContainer.scene_label_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.event_label_count.html">dcase_framework.metadata.MetaDataContainer.event_label_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.unique_scene_labels.html">dcase_framework.metadata.MetaDataContainer.unique_scene_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.unique_event_labels.html">dcase_framework.metadata.MetaDataContainer.unique_event_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.max_offset.html">dcase_framework.metadata.MetaDataContainer.max_offset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.load.html">dcase_framework.metadata.MetaDataContainer.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.save.html">dcase_framework.metadata.MetaDataContainer.save</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.event_stat_counts.html">dcase_framework.metadata.MetaDataContainer.event_stat_counts</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.MetaDataContainer.event_roll.html">dcase_framework.metadata.MetaDataContainer.event_roll</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../metadata.html#eventroll">EventRoll</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.EventRoll.html">dcase_framework.metadata.EventRoll</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.EventRoll.roll.html">dcase_framework.metadata.EventRoll.roll</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.EventRoll.pad.html">dcase_framework.metadata.EventRoll.pad</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.EventRoll.plot.html">dcase_framework.metadata.EventRoll.plot</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../metadata.html#probabilityitem">ProbabilityItem</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.html">dcase_framework.metadata.ProbabilityItem</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.id.html">dcase_framework.metadata.ProbabilityItem.id</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.file.html">dcase_framework.metadata.ProbabilityItem.file</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.label.html">dcase_framework.metadata.ProbabilityItem.label</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.timestamp.html">dcase_framework.metadata.ProbabilityItem.timestamp</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.probability.html">dcase_framework.metadata.ProbabilityItem.probability</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityItem.get_list.html">dcase_framework.metadata.ProbabilityItem.get_list</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../metadata.html#probabilitycontainer">ProbabilityContainer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.html">dcase_framework.metadata.ProbabilityContainer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.log.html">dcase_framework.metadata.ProbabilityContainer.log</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.show.html">dcase_framework.metadata.ProbabilityContainer.show</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.update.html">dcase_framework.metadata.ProbabilityContainer.update</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.file_list.html">dcase_framework.metadata.ProbabilityContainer.file_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.unique_labels.html">dcase_framework.metadata.ProbabilityContainer.unique_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.filter.html">dcase_framework.metadata.ProbabilityContainer.filter</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.get_string.html">dcase_framework.metadata.ProbabilityContainer.get_string</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.load.html">dcase_framework.metadata.ProbabilityContainer.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.metadata.ProbabilityContainer.save.html">dcase_framework.metadata.ProbabilityContainer.save</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../features.html">Features</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featurecontainer">FeatureContainer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.html">dcase_framework.features.FeatureContainer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.show.html">dcase_framework.features.FeatureContainer.show</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.log.html">dcase_framework.features.FeatureContainer.log</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.get_path.html">dcase_framework.features.FeatureContainer.get_path</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.shape.html">dcase_framework.features.FeatureContainer.shape</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.channels.html">dcase_framework.features.FeatureContainer.channels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.frames.html">dcase_framework.features.FeatureContainer.frames</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.vector_length.html">dcase_framework.features.FeatureContainer.vector_length</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.feat.html">dcase_framework.features.FeatureContainer.feat</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.stat.html">dcase_framework.features.FeatureContainer.stat</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.meta.html">dcase_framework.features.FeatureContainer.meta</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureContainer.load.html">dcase_framework.features.FeatureContainer.load</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featurerepository">FeatureRepository</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureRepository.html">dcase_framework.features.FeatureRepository</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureRepository.show.html">dcase_framework.features.FeatureRepository.show</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureRepository.log.html">dcase_framework.features.FeatureRepository.log</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureRepository.get_path.html">dcase_framework.features.FeatureRepository.get_path</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureRepository.load.html">dcase_framework.features.FeatureRepository.load</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featureextractor">FeatureExtractor</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureExtractor.html">dcase_framework.features.FeatureExtractor</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureExtractor.extract.html">dcase_framework.features.FeatureExtractor.extract</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureExtractor.get_default_parameters.html">dcase_framework.features.FeatureExtractor.get_default_parameters</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featurenormalizer">FeatureNormalizer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureNormalizer.html">dcase_framework.features.FeatureNormalizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureNormalizer.accumulate.html">dcase_framework.features.FeatureNormalizer.accumulate</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureNormalizer.finalize.html">dcase_framework.features.FeatureNormalizer.finalize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureNormalizer.normalize.html">dcase_framework.features.FeatureNormalizer.normalize</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureNormalizer.process.html">dcase_framework.features.FeatureNormalizer.process</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featurestacker">FeatureStacker</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureStacker.html">dcase_framework.features.FeatureStacker</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureStacker.normalizer.html">dcase_framework.features.FeatureStacker.normalizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureStacker.feature_vector.html">dcase_framework.features.FeatureStacker.feature_vector</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureStacker.process.html">dcase_framework.features.FeatureStacker.process</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featureaggregator">FeatureAggregator</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureAggregator.html">dcase_framework.features.FeatureAggregator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureAggregator.process.html">dcase_framework.features.FeatureAggregator.process</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../features.html#featuremasker">FeatureMasker</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureMasker.html">dcase_framework.features.FeatureMasker</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.features.FeatureMasker.process.html">dcase_framework.features.FeatureMasker.process</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../learners.html">Learners</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../learners.html#sceneclassifier">SceneClassifier</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../learners.html#sceneclassifiergmm">SceneClassifierGMM</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierGMM.html">dcase_framework.learners.SceneClassifierGMM</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierGMM.learn.html">dcase_framework.learners.SceneClassifierGMM.learn</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierGMM.predict.html">dcase_framework.learners.SceneClassifierGMM.predict</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../learners.html#sceneclassifiermlp">SceneClassifierMLP</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierMLP.html">dcase_framework.learners.SceneClassifierMLP</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierMLP.learn.html">dcase_framework.learners.SceneClassifierMLP.learn</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierMLP.predict.html">dcase_framework.learners.SceneClassifierMLP.predict</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../learners.html#sceneclassifierkerassequential">SceneClassifierKerasSequential</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierKerasSequential.html">dcase_framework.learners.SceneClassifierKerasSequential</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierKerasSequential.learn.html">dcase_framework.learners.SceneClassifierKerasSequential.learn</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.SceneClassifierKerasSequential.predict.html">dcase_framework.learners.SceneClassifierKerasSequential.predict</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../learners.html#eventdetector">EventDetector</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetector.html">dcase_framework.learners.EventDetector</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../learners.html#eventdetectorgmm">EventDetectorGMM</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorGMM.html">dcase_framework.learners.EventDetectorGMM</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorGMM.learn.html">dcase_framework.learners.EventDetectorGMM.learn</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorGMM.predict.html">dcase_framework.learners.EventDetectorGMM.predict</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../learners.html#eventdetectormlp">EventDetectorMLP</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorMLP.html">dcase_framework.learners.EventDetectorMLP</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorMLP.learn.html">dcase_framework.learners.EventDetectorMLP.learn</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorMLP.predict.html">dcase_framework.learners.EventDetectorMLP.predict</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../learners.html#eventdetectorkerassequential">EventDetectorKerasSequential</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorKerasSequential.html">dcase_framework.learners.EventDetectorKerasSequential</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorKerasSequential.learn.html">dcase_framework.learners.EventDetectorKerasSequential.learn</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../generated/dcase_framework.learners.EventDetectorKerasSequential.predict.html">dcase_framework.learners.EventDetectorKerasSequential.predict</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../learners.html#learnercontainer-base-class">LearnerContainer - Base class</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.html">dcase_framework.learners.LearnerContainer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.class_labels.html">dcase_framework.learners.LearnerContainer.class_labels</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.method.html">dcase_framework.learners.LearnerContainer.method</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.params.html">dcase_framework.learners.LearnerContainer.params</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.feature_masker.html">dcase_framework.learners.LearnerContainer.feature_masker</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.feature_normalizer.html">dcase_framework.learners.LearnerContainer.feature_normalizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.feature_stacker.html">dcase_framework.learners.LearnerContainer.feature_stacker</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.feature_aggregator.html">dcase_framework.learners.LearnerContainer.feature_aggregator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.model.html">dcase_framework.learners.LearnerContainer.model</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.set_seed.html">dcase_framework.learners.LearnerContainer.set_seed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.learners.LearnerContainer.learner_params.html">dcase_framework.learners.LearnerContainer.learner_params</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../recognizers.html">Recognizers</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../recognizers.html#scenerecognizer">SceneRecognizer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.SceneRecognizer.html">dcase_framework.recognizers.SceneRecognizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.SceneRecognizer.process.html">dcase_framework.recognizers.SceneRecognizer.process</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../recognizers.html#eventrecognizer">EventRecognizer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.EventRecognizer.html">dcase_framework.recognizers.EventRecognizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.EventRecognizer.process.html">dcase_framework.recognizers.EventRecognizer.process</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.EventRecognizer.process_ratio.html">dcase_framework.recognizers.EventRecognizer.process_ratio</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../recognizers.html#baserecognizer">BaseRecognizer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.BaseRecognizer.html">dcase_framework.recognizers.BaseRecognizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.BaseRecognizer.collapse_probabilities.html">dcase_framework.recognizers.BaseRecognizer.collapse_probabilities</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.BaseRecognizer.collapse_probabilities_windowed.html">dcase_framework.recognizers.BaseRecognizer.collapse_probabilities_windowed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.BaseRecognizer.find_contiguous_regions.html">dcase_framework.recognizers.BaseRecognizer.find_contiguous_regions</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.recognizers.BaseRecognizer.process_activity.html">dcase_framework.recognizers.BaseRecognizer.process_activity</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../data.html">Data utils</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../data.html#datasequencer">DataSequencer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataSequencer.html">dcase_framework.data.DataSequencer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataSequencer.process.html">dcase_framework.data.DataSequencer.process</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataSequencer.increase_shifting.html">dcase_framework.data.DataSequencer.increase_shifting</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../data.html#dataprocessor">DataProcessor</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.html">dcase_framework.data.DataProcessor</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.load.html">dcase_framework.data.DataProcessor.load</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.process.html">dcase_framework.data.DataProcessor.process</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.process_features.html">dcase_framework.data.DataProcessor.process_features</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.process_activity_data.html">dcase_framework.data.DataProcessor.process_activity_data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.process_data.html">dcase_framework.data.DataProcessor.process_data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataProcessor.call_method.html">dcase_framework.data.DataProcessor.call_method</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../data.html#databuffer">DataBuffer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.html">dcase_framework.data.DataBuffer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.count.html">dcase_framework.data.DataBuffer.count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.full.html">dcase_framework.data.DataBuffer.full</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.key_exists.html">dcase_framework.data.DataBuffer.key_exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.set.html">dcase_framework.data.DataBuffer.set</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.get.html">dcase_framework.data.DataBuffer.get</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.DataBuffer.clear.html">dcase_framework.data.DataBuffer.clear</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../data.html#processingchain">ProcessingChain</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.ProcessingChain.html">dcase_framework.data.ProcessingChain</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.ProcessingChain.process.html">dcase_framework.data.ProcessingChain.process</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.data.ProcessingChain.call_method.html">dcase_framework.data.ProcessingChain.call_method</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../keras_utils.html">Keras utils</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#kerasmixin">KerasMixin</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.create_model.html">dcase_framework.keras_utils.KerasMixin.create_model</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.create_callback_list.html">dcase_framework.keras_utils.KerasMixin.create_callback_list</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.create_external_metric_evaluators.html">dcase_framework.keras_utils.KerasMixin.create_external_metric_evaluators</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.prepare_data.html">dcase_framework.keras_utils.KerasMixin.prepare_data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.prepare_activity.html">dcase_framework.keras_utils.KerasMixin.prepare_activity</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.keras_model_exists.html">dcase_framework.keras_utils.KerasMixin.keras_model_exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.log_model_summary.html">dcase_framework.keras_utils.KerasMixin.log_model_summary</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.plot_model.html">dcase_framework.keras_utils.KerasMixin.plot_model</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.KerasMixin.get_processing_interval.html">dcase_framework.keras_utils.KerasMixin.get_processing_interval</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#basecallback">BaseCallback</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.BaseCallback.html">dcase_framework.keras_utils.BaseCallback</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#progressloggercallback">ProgressLoggerCallback</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.ProgressLoggerCallback.html">dcase_framework.keras_utils.ProgressLoggerCallback</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#progressplottercallback">ProgressPlotterCallback</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.ProgressPlotterCallback.html">dcase_framework.keras_utils.ProgressPlotterCallback</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#stoppercallback">StopperCallback</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.StopperCallback.html">dcase_framework.keras_utils.StopperCallback</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#stashercallback">StasherCallback</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.StasherCallback.html">dcase_framework.keras_utils.StasherCallback</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#basedatagenerator">BaseDataGenerator</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.BaseDataGenerator.html">dcase_framework.keras_utils.BaseDataGenerator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.BaseDataGenerator.input_size.html">dcase_framework.keras_utils.BaseDataGenerator.input_size</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.BaseDataGenerator.data_size.html">dcase_framework.keras_utils.BaseDataGenerator.data_size</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.BaseDataGenerator.steps_count.html">dcase_framework.keras_utils.BaseDataGenerator.steps_count</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.BaseDataGenerator.info.html">dcase_framework.keras_utils.BaseDataGenerator.info</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../keras_utils.html#featuregenerator">FeatureGenerator</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.FeatureGenerator.html">dcase_framework.keras_utils.FeatureGenerator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.keras_utils.FeatureGenerator.generator.html">dcase_framework.keras_utils.FeatureGenerator.generator</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../ui.html">User interfacing</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../ui.html#fancylogger">FancyLogger</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.html">dcase_framework.ui.FancyLogger</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.title.html">dcase_framework.ui.FancyLogger.title</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.section_header.html">dcase_framework.ui.FancyLogger.section_header</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.foot.html">dcase_framework.ui.FancyLogger.foot</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.line.html">dcase_framework.ui.FancyLogger.line</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.data.html">dcase_framework.ui.FancyLogger.data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.info.html">dcase_framework.ui.FancyLogger.info</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.debug.html">dcase_framework.ui.FancyLogger.debug</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.ui.FancyLogger.error.html">dcase_framework.ui.FancyLogger.error</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../utils.html">Utils</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../utils.html#utility-functions">Utility functions</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.setup_logging.html">dcase_framework.utils.setup_logging</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.get_parameter_hash.html">dcase_framework.utils.get_parameter_hash</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.get_class_inheritors.html">dcase_framework.utils.get_class_inheritors</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.get_byte_string.html">dcase_framework.utils.get_byte_string</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.argument_file_exists.html">dcase_framework.utils.argument_file_exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.filelist_exists.html">dcase_framework.utils.filelist_exists</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.posix_path.html">dcase_framework.utils.posix_path</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../utils.html#timer">Timer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.Timer.html">dcase_framework.utils.Timer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.Timer.start.html">dcase_framework.utils.Timer.start</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.Timer.stop.html">dcase_framework.utils.Timer.stop</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.Timer.elapsed.html">dcase_framework.utils.Timer.elapsed</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.Timer.get_string.html">dcase_framework.utils.Timer.get_string</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../utils.html#suppressstdoutandstderr">SuppressStdoutAndStderr</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.SuppressStdoutAndStderr.html">dcase_framework.utils.SuppressStdoutAndStderr</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../utils.html#simplemathstringevaluator">SimpleMathStringEvaluator</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.SimpleMathStringEvaluator.html">dcase_framework.utils.SimpleMathStringEvaluator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../generated/dcase_framework.utils.SimpleMathStringEvaluator.eval.html">dcase_framework.utils.SimpleMathStringEvaluator.eval</a></li>
</ul>
</li>
</ul>
</li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">DCASE2017 Baseline</a>
        
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html">Docs</a> &raquo;</li>
        
          <li><a href="../index.html">Module code</a> &raquo;</li>
        
      <li>dcase_framework.datasets</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for dcase_framework.datasets</h1><div class="highlight"><pre>
<span></span><span class="ch">#!/usr/bin/env python</span>
<span class="c1"># -*- coding: utf-8 -*-</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Datasets</span>
<span class="sd">==================</span>
<span class="sd">Classes for dataset handling</span>

<span class="sd">Dataset - Base class</span>
<span class="sd">^^^^^^^^^^^^^^^^^^^^</span>

<span class="sd">This is the base class, and all the specialized datasets are inherited from it. One should never use base class itself.</span>

<span class="sd">Usage examples:</span>

<span class="sd">.. code-block:: python</span>
<span class="sd">    :linenos:</span>

<span class="sd">    # Create class</span>
<span class="sd">    dataset = TUTAcousticScenes_2017_DevelopmentSet(data_path=&#39;data&#39;)</span>
<span class="sd">    # Initialize dataset, this will make sure dataset is downloaded, packages are extracted, and needed meta files are created</span>
<span class="sd">    dataset.initialize()</span>
<span class="sd">    # Show meta data</span>
<span class="sd">    dataset.meta.show()</span>
<span class="sd">    # Get all evaluation setup folds</span>
<span class="sd">    folds = dataset.folds()</span>
<span class="sd">    # Get all evaluation setup folds</span>
<span class="sd">    train_data_fold1 = dataset.train(fold=folds[0])</span>
<span class="sd">    test_data_fold1 = dataset.test(fold=folds[0])</span>

<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    Dataset</span>
<span class="sd">    Dataset.initialize</span>
<span class="sd">    Dataset.show_info</span>
<span class="sd">    Dataset.audio_files</span>
<span class="sd">    Dataset.audio_file_count</span>
<span class="sd">    Dataset.meta</span>
<span class="sd">    Dataset.meta_count</span>
<span class="sd">    Dataset.error_meta</span>
<span class="sd">    Dataset.error_meta_count</span>
<span class="sd">    Dataset.fold_count</span>
<span class="sd">    Dataset.scene_labels</span>
<span class="sd">    Dataset.scene_label_count</span>
<span class="sd">    Dataset.event_labels</span>
<span class="sd">    Dataset.event_label_count</span>
<span class="sd">    Dataset.audio_tags</span>
<span class="sd">    Dataset.audio_tag_count</span>
<span class="sd">    Dataset.download_packages</span>
<span class="sd">    Dataset.extract</span>
<span class="sd">    Dataset.train</span>
<span class="sd">    Dataset.test</span>
<span class="sd">    Dataset.eval</span>
<span class="sd">    Dataset.train_files</span>
<span class="sd">    Dataset.test_files</span>
<span class="sd">    Dataset.eval_files</span>
<span class="sd">    Dataset.validation_files</span>
<span class="sd">    Dataset.folds</span>
<span class="sd">    Dataset.file_meta</span>
<span class="sd">    Dataset.file_error_meta</span>
<span class="sd">    Dataset.file_error_meta</span>
<span class="sd">    Dataset.relative_to_absolute_path</span>
<span class="sd">    Dataset.absolute_to_relative</span>

<span class="sd">AcousticSceneDataset</span>
<span class="sd">^^^^^^^^^^^^^^^^^^^^</span>

<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    AcousticSceneDataset</span>

<span class="sd">Specialized classes inherited AcousticSceneDataset:</span>

<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    TUTAcousticScenes_2017_DevelopmentSet</span>
<span class="sd">    TUTAcousticScenes_2016_DevelopmentSet</span>
<span class="sd">    TUTAcousticScenes_2016_EvaluationSet</span>

<span class="sd">SoundEventDataset</span>
<span class="sd">^^^^^^^^^^^^^^^^^</span>

<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    SoundEventDataset</span>
<span class="sd">    SoundEventDataset.event_label_count</span>
<span class="sd">    SoundEventDataset.event_labels</span>
<span class="sd">    SoundEventDataset.train</span>
<span class="sd">    SoundEventDataset.test</span>

<span class="sd">Specialized classes inherited SoundEventDataset:</span>

<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    TUTRareSoundEvents_2017_DevelopmentSet</span>
<span class="sd">    TUTSoundEvents_2017_DevelopmentSet</span>
<span class="sd">    TUTSoundEvents_2016_DevelopmentSet</span>
<span class="sd">    TUTSoundEvents_2016_EvaluationSet</span>

<span class="sd">AudioTaggingDataset</span>
<span class="sd">^^^^^^^^^^^^^^^^^^^</span>

<span class="sd">.. autosummary::</span>
<span class="sd">    :toctree: generated/</span>

<span class="sd">    AudioTaggingDataset</span>


<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">__future__</span> <span class="k">import</span> <span class="n">print_function</span><span class="p">,</span> <span class="n">absolute_import</span>

<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">socket</span>
<span class="kn">import</span> <span class="nn">zipfile</span>
<span class="kn">import</span> <span class="nn">tarfile</span>
<span class="kn">import</span> <span class="nn">collections</span>
<span class="kn">import</span> <span class="nn">csv</span>
<span class="kn">import</span> <span class="nn">numpy</span>
<span class="kn">import</span> <span class="nn">hashlib</span>
<span class="kn">import</span> <span class="nn">yaml</span>
<span class="kn">import</span> <span class="nn">shutil</span>
<span class="kn">from</span> <span class="nn">tqdm</span> <span class="k">import</span> <span class="n">tqdm</span>
<span class="kn">from</span> <span class="nn">six</span> <span class="k">import</span> <span class="n">iteritems</span>

<span class="kn">from</span> <span class="nn">.utils</span> <span class="k">import</span> <span class="n">get_parameter_hash</span><span class="p">,</span> <span class="n">get_class_inheritors</span>
<span class="kn">from</span> <span class="nn">.decorators</span> <span class="k">import</span> <span class="n">before_and_after_function_wrapper</span>
<span class="kn">from</span> <span class="nn">.files</span> <span class="k">import</span> <span class="n">TextFile</span><span class="p">,</span> <span class="n">ParameterFile</span><span class="p">,</span> <span class="n">ParameterListFile</span><span class="p">,</span> <span class="n">AudioFile</span><span class="p">,</span> <span class="n">DictFile</span>
<span class="kn">from</span> <span class="nn">.containers</span> <span class="k">import</span> <span class="n">DottedDict</span>
<span class="kn">from</span> <span class="nn">.metadata</span> <span class="k">import</span> <span class="n">MetaDataContainer</span><span class="p">,</span> <span class="n">MetaDataItem</span>


<span class="k">def</span> <span class="nf">dataset_list</span><span class="p">(</span><span class="n">data_path</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;List of datasets available</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    data_path : str</span>
<span class="sd">        Base path for the datasets</span>
<span class="sd">    group : str</span>
<span class="sd">        Group label for the datasets, currently supported [&#39;acoustic scene&#39;, &#39;sound event&#39;, &#39;audio tagging&#39;]</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    str</span>
<span class="sd">        Multi line string containing dataset table</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">output</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">output</span> <span class="o">+=</span> <span class="s1">&#39;  Dataset list</span><span class="se">\n</span><span class="s1">&#39;</span>
    <span class="n">output</span> <span class="o">+=</span> <span class="s1">&#39;  </span><span class="si">{class_name:&lt;45s}</span><span class="s1"> | </span><span class="si">{group:20s}</span><span class="s1"> | </span><span class="si">{valid:5s}</span><span class="s1"> | </span><span class="si">{files:10s}</span><span class="s1"> |</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
        <span class="n">class_name</span><span class="o">=</span><span class="s1">&#39;Class Name&#39;</span><span class="p">,</span>
        <span class="n">group</span><span class="o">=</span><span class="s1">&#39;Group&#39;</span><span class="p">,</span>
        <span class="n">valid</span><span class="o">=</span><span class="s1">&#39;Valid&#39;</span><span class="p">,</span>
        <span class="n">files</span><span class="o">=</span><span class="s1">&#39;Files&#39;</span>
    <span class="p">)</span>
    <span class="n">output</span> <span class="o">+=</span> <span class="s1">&#39;  </span><span class="si">{class_name:&lt;45s}</span><span class="s1"> + </span><span class="si">{group:20s}</span><span class="s1"> + </span><span class="si">{valid:5s}</span><span class="s1"> + </span><span class="si">{files:10s}</span><span class="s1"> +</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
        <span class="n">class_name</span><span class="o">=</span><span class="s1">&#39;-&#39;</span> <span class="o">*</span> <span class="mi">45</span><span class="p">,</span>
        <span class="n">group</span><span class="o">=</span><span class="s1">&#39;-&#39;</span> <span class="o">*</span> <span class="mi">20</span><span class="p">,</span>
        <span class="n">valid</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="o">*</span><span class="mi">5</span><span class="p">,</span>
        <span class="n">files</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="o">*</span><span class="mi">10</span>
    <span class="p">)</span>

    <span class="k">def</span> <span class="nf">get_empty_row</span><span class="p">():</span>
        <span class="k">return</span> <span class="s1">&#39;  </span><span class="si">{class_name:&lt;45s}</span><span class="s1"> | </span><span class="si">{group:20s}</span><span class="s1"> | </span><span class="si">{valid:5s}</span><span class="s1"> | </span><span class="si">{files:10s}</span><span class="s1"> |</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
            <span class="n">class_name</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span>
            <span class="n">group</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span>
            <span class="n">valid</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span>
            <span class="n">files</span><span class="o">=</span><span class="s1">&#39;&#39;</span>
        <span class="p">)</span>

    <span class="k">def</span> <span class="nf">get_row</span><span class="p">(</span><span class="n">d</span><span class="p">):</span>
        <span class="n">file_count</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="k">if</span> <span class="n">d</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="n">file_count</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">d</span><span class="o">.</span><span class="n">meta</span><span class="p">)</span>

        <span class="k">return</span> <span class="s1">&#39;  </span><span class="si">{class_name:&lt;45s}</span><span class="s1"> | </span><span class="si">{group:20s}</span><span class="s1"> | </span><span class="si">{valid:5s}</span><span class="s1"> | </span><span class="si">{files:10s}</span><span class="s1"> |</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
            <span class="n">class_name</span><span class="o">=</span><span class="n">d</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
            <span class="n">group</span><span class="o">=</span><span class="n">d</span><span class="o">.</span><span class="n">dataset_group</span><span class="p">,</span>
            <span class="n">valid</span><span class="o">=</span><span class="s1">&#39;Yes&#39;</span> <span class="k">if</span> <span class="n">d</span><span class="o">.</span><span class="n">check_filelist</span><span class="p">()</span> <span class="k">else</span> <span class="s1">&#39;No&#39;</span><span class="p">,</span>
            <span class="n">files</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">file_count</span><span class="p">)</span> <span class="k">if</span> <span class="n">file_count</span> <span class="k">else</span> <span class="s1">&#39;&#39;</span>
        <span class="p">)</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">group</span> <span class="o">==</span> <span class="s1">&#39;acoustic scene&#39;</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">dataset_class</span> <span class="ow">in</span> <span class="n">get_class_inheritors</span><span class="p">(</span><span class="n">AcousticSceneDataset</span><span class="p">):</span>
            <span class="n">d</span> <span class="o">=</span> <span class="n">dataset_class</span><span class="p">(</span><span class="n">data_path</span><span class="o">=</span><span class="n">data_path</span><span class="p">)</span>
            <span class="n">output</span> <span class="o">+=</span> <span class="n">get_row</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">group</span> <span class="o">==</span> <span class="s1">&#39;sound event&#39;</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">dataset_class</span> <span class="ow">in</span> <span class="n">get_class_inheritors</span><span class="p">(</span><span class="n">SoundEventDataset</span><span class="p">):</span>
            <span class="n">d</span> <span class="o">=</span> <span class="n">dataset_class</span><span class="p">(</span><span class="n">data_path</span><span class="o">=</span><span class="n">data_path</span><span class="p">)</span>
            <span class="n">output</span> <span class="o">+=</span> <span class="n">get_row</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">group</span> <span class="o">==</span> <span class="s1">&#39;audio tagging&#39;</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">dataset_class</span> <span class="ow">in</span> <span class="n">get_class_inheritors</span><span class="p">(</span><span class="n">AudioTaggingDataset</span><span class="p">):</span>
            <span class="n">d</span> <span class="o">=</span> <span class="n">dataset_class</span><span class="p">(</span><span class="n">data_path</span><span class="o">=</span><span class="n">data_path</span><span class="p">)</span>
            <span class="n">output</span> <span class="o">+=</span> <span class="n">get_row</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>

    <span class="k">return</span> <span class="n">output</span>


<span class="k">def</span> <span class="nf">dataset_factory</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Factory to get correct dataset class based on name</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    dataset_class_name : str</span>
<span class="sd">        Class name</span>
<span class="sd">        Default value &quot;None&quot;</span>

<span class="sd">    Raises</span>
<span class="sd">    ------</span>
<span class="sd">    NameError</span>
<span class="sd">        Class does not exists</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    Dataset class</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">dataset_class_name</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;dataset_class_name&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="k">return</span> <span class="nb">eval</span><span class="p">(</span><span class="n">dataset_class_name</span><span class="p">)(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
    <span class="k">except</span> <span class="ne">NameError</span><span class="p">:</span>
        <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: No valid dataset given [</span><span class="si">{dataset_class_name}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
            <span class="n">name</span><span class="o">=</span><span class="s1">&#39;dataset_factory&#39;</span><span class="p">,</span>
            <span class="n">dataset_class_name</span><span class="o">=</span><span class="n">dataset_class_name</span>
        <span class="p">)</span>

        <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s1">&#39;dataset_factory&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
        <span class="k">raise</span> <span class="ne">NameError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>


<div class="viewcode-block" id="Dataset"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.html#dcase_framework.datasets.Dataset">[docs]</a><span class="k">class</span> <span class="nc">Dataset</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Dataset base class</span>

<span class="sd">    The specific dataset classes are inherited from this class, and only needed methods are reimplemented.</span>

<span class="sd">    &quot;&quot;&quot;</span>

<div class="viewcode-block" id="Dataset.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.html#dcase_framework.datasets.Dataset.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Constructor</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        name : str</span>
<span class="sd">        storage_name : str</span>
<span class="sd">        data_path : str</span>
<span class="sd">            Basepath where the dataset is stored.</span>
<span class="sd">            (Default value=&#39;data&#39;)</span>
<span class="sd">        logger : logger</span>
<span class="sd">            Instance of logging</span>
<span class="sd">            Default value &quot;none&quot;</span>
<span class="sd">        show_progress_in_console : bool</span>
<span class="sd">            Show progress in console.</span>
<span class="sd">            Default value &quot;True&quot;</span>
<span class="sd">        log_system_progress : bool</span>
<span class="sd">            Show progress in log.</span>
<span class="sd">            Default value &quot;False&quot;</span>
<span class="sd">        use_ascii_progress_bar : bool</span>
<span class="sd">            Show progress bar using ASCII characters. Use this if your console does not support UTF-8 characters.</span>
<span class="sd">            Default value &quot;False&quot;</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;logger&#39;</span><span class="p">)</span> <span class="ow">or</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;show_progress_in_console&#39;</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">log_system_progress</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;log_system_progress&#39;</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;use_ascii_progress_bar&#39;</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span>

        <span class="c1"># Dataset name</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="s1">&#39;dataset&#39;</span><span class="p">)</span>

        <span class="c1"># Folder name for dataset</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">storage_name</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;dataset&#39;</span><span class="p">)</span>

        <span class="c1"># Path to the dataset</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;data_path&#39;</span><span class="p">,</span> <span class="s1">&#39;data&#39;</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">storage_name</span><span class="p">)</span>

        <span class="c1"># Evaluation setup folder</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_folder</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;evaluation_setup_folder&#39;</span><span class="p">,</span> <span class="s1">&#39;evaluation_setup&#39;</span><span class="p">)</span>

        <span class="c1"># Path to the folder containing evaluation setup files</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_folder</span><span class="p">)</span>

        <span class="c1"># Meta data file, csv-format</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">meta_filename</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;meta_filename&#39;</span><span class="p">,</span> <span class="s1">&#39;meta.txt&#39;</span><span class="p">)</span>

        <span class="c1"># Path to meta data file</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_filename</span><span class="p">))</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

        <span class="c1"># Error meta data file, csv-format</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">error_meta_filename</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;error_meta_filename&#39;</span><span class="p">,</span> <span class="s1">&#39;error.txt&#39;</span><span class="p">)</span>

        <span class="c1"># Path to error meta data file</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">error_meta_file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_meta_filename</span><span class="p">)</span>

        <span class="c1"># Hash file to detect removed or added files</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filelisthash_filename</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;filelisthash_filename&#39;</span><span class="p">,</span> <span class="s1">&#39;filelist.python.hash&#39;</span><span class="p">)</span>

        <span class="c1"># Dirs to be excluded when calculating filelist hash</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filelisthash_exclude_dirs</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;filelisthash_exclude_dirs&#39;</span><span class="p">,</span> <span class="p">[])</span>

        <span class="c1"># Number of evaluation folds</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">1</span>

        <span class="c1"># List containing dataset package items</span>
        <span class="c1"># Define this in the inherited class.</span>
        <span class="c1"># Format:</span>
        <span class="c1"># {</span>
        <span class="c1">#        &#39;remote_package&#39;: download_url,</span>
        <span class="c1">#        &#39;local_package&#39;: os.path.join(self.local_path, &#39;name_of_downloaded_package&#39;),</span>
        <span class="c1">#        &#39;local_audio_path&#39;: os.path.join(self.local_path, &#39;name_of_folder_containing_audio_files&#39;),</span>
        <span class="c1"># }</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="c1"># List of audio files</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">files</span> <span class="o">=</span> <span class="kc">None</span>

        <span class="c1"># List of audio error meta data dict</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">error_meta_data</span> <span class="o">=</span> <span class="kc">None</span>

        <span class="c1"># Training meta data for folds</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span> <span class="o">=</span> <span class="p">{}</span>

        <span class="c1"># Testing meta data for folds</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span> <span class="o">=</span> <span class="p">{}</span>

        <span class="c1"># Evaluation meta data for folds</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span> <span class="o">=</span> <span class="p">{}</span>

        <span class="c1"># Recognized audio extensions</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">audio_extensions</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;wav&#39;</span><span class="p">,</span> <span class="s1">&#39;flac&#39;</span><span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">default_audio_extension</span> <span class="o">=</span> <span class="s1">&#39;wav&#39;</span>

        <span class="c1"># Reference data presence flag, by default dataset should have reference data present.</span>
        <span class="c1"># However, some evaluation dataset might not have</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">reference_data_present</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Info fields for dataset</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">authors</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">name_remote</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">url</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">audio_source</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">audio_type</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">recording_device_model</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">microphone_model</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span></div>

<div class="viewcode-block" id="Dataset.initialize"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.initialize.html#dcase_framework.datasets.Dataset.initialize">[docs]</a>    <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="c1"># Create the dataset path if does not exist</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">):</span>
            <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">check_filelist</span><span class="p">():</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">download_packages</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">extract</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_save_filelist_hash</span><span class="p">()</span>

        <span class="k">return</span> <span class="bp">self</span></div>

<div class="viewcode-block" id="Dataset.show_info"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.show_info.html#dcase_framework.datasets.Dataset.show_info">[docs]</a>    <span class="k">def</span> <span class="nf">show_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">DottedDict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span><span class="p">)</span><span class="o">.</span><span class="n">show</span><span class="p">()</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">audio_files</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Get all audio files in the dataset</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        filelist : list</span>
<span class="sd">            File list with absolute paths</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">files</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">files</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span><span class="p">:</span>
                <span class="n">path</span> <span class="o">=</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;local_audio_path&#39;</span><span class="p">]</span>
                <span class="k">if</span> <span class="n">path</span><span class="p">:</span>
                    <span class="n">l</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
                    <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">l</span><span class="p">:</span>
                        <span class="n">file_name</span><span class="p">,</span> <span class="n">file_extension</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
                        <span class="k">if</span> <span class="n">file_extension</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">audio_extensions</span><span class="p">:</span>
                            <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">f</span><span class="p">))</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">files</span><span class="p">:</span>
                                <span class="bp">self</span><span class="o">.</span><span class="n">files</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">f</span><span class="p">)))</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">files</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">files</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">audio_file_count</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Get number of audio files in dataset</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        filecount : int</span>
<span class="sd">            Number of audio files</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">audio_files</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">meta</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Get meta data for dataset. If not already read from disk, data is read and returned.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        meta_container : list</span>
<span class="sd">            List containing meta data as dict.</span>

<span class="sd">        Raises</span>
<span class="sd">        -------</span>
<span class="sd">        IOError</span>
<span class="sd">            meta file not found.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">empty</span><span class="p">():</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Meta file not found [</span><span class="si">{filename}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                    <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filename</span>
                <span class="p">)</span>

                <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
                <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">meta_count</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Number of meta data items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        meta_item_count : int</span>
<span class="sd">            Meta data item count</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">error_meta</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Get audio error meta data for dataset. If not already read from disk, data is read and returned.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Raises</span>
<span class="sd">        -------</span>
<span class="sd">        IOError:</span>
<span class="sd">            audio error meta file not found.</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        error_meta_data : list</span>
<span class="sd">            List containing audio error meta data as dict.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_meta_data</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">error_meta_data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">error_meta_file</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_meta_data</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">error_meta_data</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Error meta file not found [</span><span class="si">{filename}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                                                                                  <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">error_meta_file</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
                <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_meta_data</span>

<div class="viewcode-block" id="Dataset.error_meta_count"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.error_meta_count.html#dcase_framework.datasets.Dataset.error_meta_count">[docs]</a>    <span class="k">def</span> <span class="nf">error_meta_count</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Number of error meta data items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        meta_item_count : int</span>
<span class="sd">            Meta data item count</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">error_meta</span><span class="p">)</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">fold_count</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Number of fold in the evaluation setup.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        fold_count : int</span>
<span class="sd">            Number of folds</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">scene_labels</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of unique scene labels in the meta data.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        labels : list</span>
<span class="sd">            List of scene labels in alphabetical order.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">unique_scene_labels</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">scene_label_count</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Number of unique scene labels in the meta data.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        scene_label_count : int</span>
<span class="sd">            Number of unique scene labels.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">scene_label_count</span>

<div class="viewcode-block" id="Dataset.event_labels"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.event_labels.html#dcase_framework.datasets.Dataset.event_labels">[docs]</a>    <span class="k">def</span> <span class="nf">event_labels</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of unique event labels in the meta data.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        labels : list</span>
<span class="sd">            List of event labels in alphabetical order.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">unique_event_labels</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">event_label_count</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Number of unique event labels in the meta data.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        event_label_count : int</span>
<span class="sd">            Number of unique event labels</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">event_label_count</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">audio_tags</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of unique audio tags in the meta data.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        labels : list</span>
<span class="sd">            List of audio tags in alphabetical order.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">tags</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta</span><span class="p">:</span>
            <span class="k">if</span> <span class="s1">&#39;tags&#39;</span> <span class="ow">in</span> <span class="n">item</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">tag</span> <span class="ow">in</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;tags&#39;</span><span class="p">]:</span>
                    <span class="k">if</span> <span class="n">tag</span> <span class="ow">and</span> <span class="n">tag</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">tags</span><span class="p">:</span>
                        <span class="n">tags</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tag</span><span class="p">)</span>
        <span class="n">tags</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">tags</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">audio_tag_count</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Number of unique audio tags in the meta data.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        audio_tag_count : int</span>
<span class="sd">            Number of unique audio tags</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">audio_tags</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Getting meta data item</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        i : int</span>
<span class="sd">            item id</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        meta_data : dict</span>
<span class="sd">            Meta data item</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="p">):</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

    <span class="k">def</span> <span class="nf">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Iterator for meta data items</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        Nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        Nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">meta</span> <span class="o">=</span> <span class="bp">self</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>

        <span class="c1"># yield window while it&#39;s valid</span>
        <span class="k">while</span> <span class="n">meta</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">yield</span> <span class="n">meta</span>
            <span class="c1"># get next item</span>
            <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">meta</span> <span class="o">=</span> <span class="bp">self</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>

<div class="viewcode-block" id="Dataset.download_packages"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.download_packages.html#dcase_framework.datasets.Dataset.download_packages">[docs]</a>    <span class="k">def</span> <span class="nf">download_packages</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Download dataset packages over the internet to the local path</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        Nothing</span>

<span class="sd">        Raises</span>
<span class="sd">        -------</span>
<span class="sd">        IOError</span>
<span class="sd">            Download failed.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="kn">from</span> <span class="nn">urllib.request</span> <span class="k">import</span> <span class="n">urlretrieve</span>
        <span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
            <span class="kn">from</span> <span class="nn">urllib</span> <span class="k">import</span> <span class="n">urlretrieve</span>

        <span class="c1"># Set socket timeout</span>
        <span class="n">socket</span><span class="o">.</span><span class="n">setdefaulttimeout</span><span class="p">(</span><span class="mi">120</span><span class="p">)</span>

        <span class="n">item_progress</span> <span class="o">=</span> <span class="n">tqdm</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">package_list</span><span class="p">,</span>
                             <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &lt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Download package list&#39;</span><span class="p">),</span>
                             <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                             <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                             <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                             <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">item_progress</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;remote_package&#39;</span><span class="p">]</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;local_package&#39;</span><span class="p">]):</span>

                    <span class="k">def</span> <span class="nf">progress_hook</span><span class="p">(</span><span class="n">t</span><span class="p">):</span>
                        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">                        Wraps tqdm instance. Don&#39;t forget to close() or __exit__()</span>
<span class="sd">                        the tqdm instance once you&#39;re done with it (easiest using `with` syntax).</span>
<span class="sd">                        &quot;&quot;&quot;</span>

                        <span class="n">last_b</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span>

                        <span class="k">def</span> <span class="nf">inner</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">bsize</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">tsize</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
                            <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">                            b  : int, optional</span>
<span class="sd">                                Number of blocks just transferred [default: 1].</span>
<span class="sd">                            bsize  : int, optional</span>
<span class="sd">                                Size of each block (in tqdm units) [default: 1].</span>
<span class="sd">                            tsize  : int, optional</span>
<span class="sd">                                Total size (in tqdm units). If [default: None] remains unchanged.</span>
<span class="sd">                            &quot;&quot;&quot;</span>
                            <span class="k">if</span> <span class="n">tsize</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                                <span class="n">t</span><span class="o">.</span><span class="n">total</span> <span class="o">=</span> <span class="n">tsize</span>
                            <span class="n">t</span><span class="o">.</span><span class="n">update</span><span class="p">((</span><span class="n">b</span> <span class="o">-</span> <span class="n">last_b</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">*</span> <span class="n">bsize</span><span class="p">)</span>
                            <span class="n">last_b</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">b</span>

                        <span class="k">return</span> <span class="n">inner</span>

                    <span class="n">remote_file</span> <span class="o">=</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;remote_package&#39;</span><span class="p">]</span>
                    <span class="n">tmp_file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;tmp_file&#39;</span><span class="p">)</span>
                    <span class="k">with</span> <span class="n">tqdm</span><span class="p">(</span><span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &gt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">remote_file</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">])[</span><span class="mi">0</span><span class="p">]),</span>
                              <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                              <span class="n">unit</span><span class="o">=</span><span class="s1">&#39;B&#39;</span><span class="p">,</span>
                              <span class="n">unit_scale</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                              <span class="n">miniters</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
                              <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                              <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                              <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span><span class="p">)</span> <span class="k">as</span> <span class="n">t</span><span class="p">:</span>

                        <span class="n">local_filename</span><span class="p">,</span> <span class="n">headers</span> <span class="o">=</span> <span class="n">urlretrieve</span><span class="p">(</span>
                            <span class="n">remote_file</span><span class="p">,</span>
                            <span class="n">filename</span><span class="o">=</span><span class="n">tmp_file</span><span class="p">,</span>
                            <span class="n">reporthook</span><span class="o">=</span><span class="n">progress_hook</span><span class="p">(</span><span class="n">t</span><span class="p">),</span>
                            <span class="n">data</span><span class="o">=</span><span class="kc">None</span>
                        <span class="p">)</span>

                    <span class="n">os</span><span class="o">.</span><span class="n">rename</span><span class="p">(</span><span class="n">tmp_file</span><span class="p">,</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;local_package&#39;</span><span class="p">])</span>

            <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
                <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Download failed [</span><span class="si">{filename}</span><span class="s1">] [</span><span class="si">{errno}</span><span class="s1">: </span><span class="si">{strerror}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                    <span class="n">filename</span><span class="o">=</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;remote_package&#39;</span><span class="p">],</span>
                    <span class="n">errno</span><span class="o">=</span><span class="n">e</span><span class="o">.</span><span class="n">errno</span> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s1">&#39;errno&#39;</span><span class="p">)</span> <span class="k">else</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
                    <span class="n">strerror</span><span class="o">=</span><span class="n">e</span><span class="o">.</span><span class="n">strerror</span> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s1">&#39;strerror&#39;</span><span class="p">)</span> <span class="k">else</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
                <span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
                <span class="k">raise</span></div>

    <span class="nd">@before_and_after_function_wrapper</span>
<div class="viewcode-block" id="Dataset.extract"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.extract.html#dcase_framework.datasets.Dataset.extract">[docs]</a>    <span class="k">def</span> <span class="nf">extract</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Extract the dataset packages</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        Nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">item_progress</span> <span class="o">=</span> <span class="n">tqdm</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">package_list</span><span class="p">,</span>
                             <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &lt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Extract packages&#39;</span><span class="p">),</span>
                             <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                             <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                             <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                             <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">item_id</span><span class="p">,</span> <span class="n">item</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">item_progress</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;local_package&#39;</span><span class="p">]</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;local_package&#39;</span><span class="p">]):</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">log_system_progress</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;  </span><span class="si">{title:&lt;15s}</span><span class="s1"> [</span><span class="si">{item_id:d}</span><span class="s1">/</span><span class="si">{total:d}</span><span class="s1">] </span><span class="si">{package:&lt;30s}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">title</span><span class="o">=</span><span class="s1">&#39;Extract packages &#39;</span><span class="p">,</span>
                        <span class="n">item_id</span><span class="o">=</span><span class="n">item_id</span><span class="p">,</span>
                        <span class="n">total</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">item_progress</span><span class="p">),</span>
                        <span class="n">package</span><span class="o">=</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;local_package&#39;</span><span class="p">])</span>
                    <span class="p">)</span>

                <span class="k">if</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;local_package&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s1">&#39;.zip&#39;</span><span class="p">):</span>

                    <span class="k">with</span> <span class="n">zipfile</span><span class="o">.</span><span class="n">ZipFile</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;local_package&#39;</span><span class="p">],</span> <span class="s2">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">z</span><span class="p">:</span>
                        <span class="c1"># Trick to omit first level folder</span>
                        <span class="n">parts</span> <span class="o">=</span> <span class="p">[]</span>
                        <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">z</span><span class="o">.</span><span class="n">namelist</span><span class="p">():</span>
                            <span class="k">if</span> <span class="ow">not</span> <span class="n">name</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">):</span>
                                <span class="n">parts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
                        <span class="n">prefix</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">commonprefix</span><span class="p">(</span><span class="n">parts</span><span class="p">)</span> <span class="ow">or</span> <span class="s1">&#39;&#39;</span>

                        <span class="k">if</span> <span class="n">prefix</span><span class="p">:</span>
                            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">prefix</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                                <span class="n">prefix_</span> <span class="o">=</span> <span class="nb">list</span><span class="p">()</span>
                                <span class="n">prefix_</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">prefix</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                                <span class="n">prefix</span> <span class="o">=</span> <span class="n">prefix_</span>

                            <span class="n">prefix</span> <span class="o">=</span> <span class="s1">&#39;/&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">prefix</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span>
                        <span class="n">offset</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">prefix</span><span class="p">)</span>

                        <span class="c1"># Start extraction</span>
                        <span class="n">members</span> <span class="o">=</span> <span class="n">z</span><span class="o">.</span><span class="n">infolist</span><span class="p">()</span>
                        <span class="n">file_count</span> <span class="o">=</span> <span class="mi">1</span>
                        <span class="n">progress</span> <span class="o">=</span> <span class="n">tqdm</span><span class="p">(</span><span class="n">members</span><span class="p">,</span>
                                        <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &lt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Extract&#39;</span><span class="p">),</span>
                                        <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                                        <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                        <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                                        <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span><span class="p">)</span>
                        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">member</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">progress</span><span class="p">):</span>
                            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">log_system_progress</span><span class="p">:</span>
                                <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;  </span><span class="si">{title:&lt;15s}</span><span class="s1"> [</span><span class="si">{item_id:d}</span><span class="s1">/</span><span class="si">{total:d}</span><span class="s1">] </span><span class="si">{file:&lt;30s}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                                    <span class="n">title</span><span class="o">=</span><span class="s1">&#39;Extract &#39;</span><span class="p">,</span>
                                    <span class="n">item_id</span><span class="o">=</span><span class="n">i</span><span class="p">,</span>
                                    <span class="n">total</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">progress</span><span class="p">),</span>
                                    <span class="n">file</span><span class="o">=</span><span class="n">member</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span>
                                <span class="p">)</span>

                            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">member</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span> <span class="o">&gt;</span> <span class="n">offset</span><span class="p">:</span>
                                <span class="n">member</span><span class="o">.</span><span class="n">filename</span> <span class="o">=</span> <span class="n">member</span><span class="o">.</span><span class="n">filename</span><span class="p">[</span><span class="n">offset</span><span class="p">:]</span>
                                <span class="n">progress</span><span class="o">.</span><span class="n">set_description</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{0: &gt;35s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">member</span><span class="o">.</span><span class="n">filename</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]))</span>
                                <span class="n">progress</span><span class="o">.</span><span class="n">update</span><span class="p">()</span>
                                <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="n">member</span><span class="o">.</span><span class="n">filename</span><span class="p">)):</span>
                                    <span class="k">try</span><span class="p">:</span>
                                        <span class="k">if</span> <span class="s1">&#39;zip_password&#39;</span> <span class="ow">in</span> <span class="n">item</span><span class="p">:</span>
                                            <span class="n">z</span><span class="o">.</span><span class="n">extract</span><span class="p">(</span><span class="n">member</span><span class="o">=</span><span class="n">member</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="n">pwd</span><span class="o">=</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;zip_password&#39;</span><span class="p">])</span>
                                        <span class="k">else</span><span class="p">:</span>
                                            <span class="n">z</span><span class="o">.</span><span class="n">extract</span><span class="p">(</span><span class="n">member</span><span class="o">=</span><span class="n">member</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">)</span>
                                    <span class="k">except</span> <span class="ne">KeyboardInterrupt</span><span class="p">:</span>
                                        <span class="c1"># Delete latest file, since most likely it was not extracted fully</span>
                                        <span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="n">member</span><span class="o">.</span><span class="n">filename</span><span class="p">))</span>

                                        <span class="c1"># Quit</span>
                                        <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span>

                                <span class="n">file_count</span> <span class="o">+=</span> <span class="mi">1</span>

                <span class="k">elif</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;local_package&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s1">&#39;.tar.gz&#39;</span><span class="p">):</span>
                    <span class="n">tar</span> <span class="o">=</span> <span class="n">tarfile</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;local_package&#39;</span><span class="p">],</span> <span class="s2">&quot;r:gz&quot;</span><span class="p">)</span>
                    <span class="n">progress</span> <span class="o">=</span> <span class="n">tqdm</span><span class="p">(</span><span class="n">tar</span><span class="p">,</span>
                                    <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &lt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Extract&#39;</span><span class="p">),</span>
                                    <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                                    <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                    <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                                    <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span><span class="p">)</span>
                    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">tar_info</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">progress</span><span class="p">):</span>
                        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">log_system_progress</span><span class="p">:</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;  </span><span class="si">{title:&lt;15s}</span><span class="s1"> [</span><span class="si">{item_id:d}</span><span class="s1">/</span><span class="si">{total:d}</span><span class="s1">] </span><span class="si">{file:&lt;30s}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                                <span class="n">title</span><span class="o">=</span><span class="s1">&#39;Extract &#39;</span><span class="p">,</span>
                                <span class="n">item_id</span><span class="o">=</span><span class="n">i</span><span class="p">,</span>
                                <span class="n">total</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">progress</span><span class="p">),</span>
                                <span class="n">file</span><span class="o">=</span><span class="n">tar_info</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
                            <span class="p">)</span>

                        <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="n">tar_info</span><span class="o">.</span><span class="n">name</span><span class="p">)):</span>
                            <span class="n">tar</span><span class="o">.</span><span class="n">extract</span><span class="p">(</span><span class="n">tar_info</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">)</span>
                        <span class="n">tar</span><span class="o">.</span><span class="n">members</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="n">tar</span><span class="o">.</span><span class="n">close</span><span class="p">()</span></div>

    <span class="k">def</span> <span class="nf">_get_filelist</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exclude_dirs</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of files under local_path</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        exclude_dirs : list of str</span>
<span class="sd">            List of directories to be excluded</span>
<span class="sd">            Default value &quot;[]&quot;</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        filelist: list</span>
<span class="sd">            File list</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">exclude_dirs</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">exclude_dirs</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="n">filelist</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">path</span><span class="p">,</span> <span class="n">subdirs</span><span class="p">,</span> <span class="n">files</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">walk</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">files</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">name</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filelisthash_filename</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">path</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">exclude_dirs</span><span class="p">:</span>
                    <span class="n">filelist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">name</span><span class="p">))</span>

        <span class="k">return</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">filelist</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">check_filelist</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Generates hash from file list and check does it matches with one saved in filelist.hash.</span>
<span class="sd">        If some files have been deleted or added, checking will result False.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        result: bool</span>
<span class="sd">            Result</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">filelisthash_filename</span><span class="p">)):</span>
            <span class="n">old_hash_value</span> <span class="o">=</span> <span class="n">TextFile</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">filelisthash_filename</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">file_list</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_filelist</span><span class="p">(</span><span class="n">exclude_dirs</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">filelisthash_exclude_dirs</span><span class="p">)</span>
            <span class="n">new_hash_value</span> <span class="o">=</span> <span class="n">get_parameter_hash</span><span class="p">(</span><span class="n">file_list</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">old_hash_value</span> <span class="o">!=</span> <span class="n">new_hash_value</span><span class="p">:</span>
                <span class="k">return</span> <span class="kc">False</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">return</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="nf">_save_filelist_hash</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Generates file list hash, and saves it as filelist.hash under local_path.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        Nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        Nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">filelist</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_filelist</span><span class="p">()</span>

        <span class="n">hash_value</span> <span class="o">=</span> <span class="n">get_parameter_hash</span><span class="p">(</span><span class="n">filelist</span><span class="p">)</span>

        <span class="n">TextFile</span><span class="p">([</span><span class="n">hash_value</span><span class="p">],</span> <span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">filelisthash_filename</span><span class="p">))</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>

<div class="viewcode-block" id="Dataset.train"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.train.html#dcase_framework.datasets.Dataset.train">[docs]</a>    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of training items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to training set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                    <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span><span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;train&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span>

            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span></div>

<div class="viewcode-block" id="Dataset.test"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.test.html#dcase_framework.datasets.Dataset.test">[docs]</a>    <span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of testing items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to testing set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                    <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span><span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;test&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>

            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span>

            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span></div>

<div class="viewcode-block" id="Dataset.eval"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.eval.html#dcase_framework.datasets.Dataset.eval">[docs]</a>    <span class="k">def</span> <span class="nf">eval</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of evaluation items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to testing set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                    <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span><span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;evaluate&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span>

            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span></div>

<div class="viewcode-block" id="Dataset.train_files"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.train_files.html#dcase_framework.datasets.Dataset.train_files">[docs]</a>    <span class="k">def</span> <span class="nf">train_files</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of training files.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of filenames</span>
<span class="sd">            List containing all files assigned to training set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">train</span><span class="p">(</span><span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">)</span><span class="o">.</span><span class="n">file_list</span></div>

<div class="viewcode-block" id="Dataset.test_files"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.test_files.html#dcase_framework.datasets.Dataset.test_files">[docs]</a>    <span class="k">def</span> <span class="nf">test_files</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of testing files.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of filenames</span>
<span class="sd">            List containing all files assigned to testing set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">)</span><span class="o">.</span><span class="n">file_list</span></div>

<div class="viewcode-block" id="Dataset.eval_files"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.eval_files.html#dcase_framework.datasets.Dataset.eval_files">[docs]</a>    <span class="k">def</span> <span class="nf">eval_files</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of evaluation files.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of filenames</span>
<span class="sd">            List containing all files assigned to testing set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">eval</span><span class="p">(</span><span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">)</span><span class="o">.</span><span class="n">file_list</span></div>

<div class="viewcode-block" id="Dataset.validation_files"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.validation_files.html#dcase_framework.datasets.Dataset.validation_files">[docs]</a>    <span class="k">def</span> <span class="nf">validation_files</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of validation files if they are specified by the dataset. Validation files are always subset of training files.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of filenames</span>
<span class="sd">            List containing all files assigned to training set for given fold.</span>
<span class="sd">            (Default value=[])</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">[]</span></div>

<div class="viewcode-block" id="Dataset.folds"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.folds.html#dcase_framework.datasets.Dataset.folds">[docs]</a>    <span class="k">def</span> <span class="nf">folds</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s1">&#39;folds&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of fold ids</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        mode : str {&#39;folds&#39;,&#39;full&#39;}</span>
<span class="sd">            Fold setup type, possible values are &#39;folds&#39; and &#39;full&#39;. In &#39;full&#39; mode fold number is set 0 and all data is used for training.</span>
<span class="sd">            (Default value=folds)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of integers</span>
<span class="sd">            Fold ids</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">&#39;folds&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">&#39;full&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span></div>

<div class="viewcode-block" id="Dataset.file_meta"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.file_meta.html#dcase_framework.datasets.Dataset.file_meta">[docs]</a>    <span class="k">def</span> <span class="nf">file_meta</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Meta data for given file</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        filename : str</span>
<span class="sd">            File name</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data related to given file.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">filename</span><span class="p">))</span></div>

<div class="viewcode-block" id="Dataset.file_error_meta"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.file_error_meta.html#dcase_framework.datasets.Dataset.file_error_meta">[docs]</a>    <span class="k">def</span> <span class="nf">file_error_meta</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Error meta data for given file</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        filename : str</span>
<span class="sd">            File name</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all error meta data related to given file.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_meta</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">filename</span><span class="p">))</span></div>

<div class="viewcode-block" id="Dataset.relative_to_absolute_path"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.relative_to_absolute_path.html#dcase_framework.datasets.Dataset.relative_to_absolute_path">[docs]</a>    <span class="k">def</span> <span class="nf">relative_to_absolute_path</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Converts relative path into absolute path.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        path : str</span>
<span class="sd">            Relative path</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        path : str</span>
<span class="sd">            Absolute path</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="n">path</span><span class="p">)))</span></div>

<div class="viewcode-block" id="Dataset.absolute_to_relative"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.Dataset.absolute_to_relative.html#dcase_framework.datasets.Dataset.absolute_to_relative">[docs]</a>    <span class="k">def</span> <span class="nf">absolute_to_relative</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Converts absolute path into relative path.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        path : str</span>
<span class="sd">            Absolute path</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        path : str</span>
<span class="sd">            Relative path</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">path</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">)):</span>
            <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">relpath</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">path</span></div>

    <span class="k">def</span> <span class="nf">_get_evaluation_setup_filename</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;train&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">file_extension</span><span class="o">=</span><span class="s1">&#39;txt&#39;</span><span class="p">):</span>
        <span class="n">parts</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="n">scene_label</span><span class="p">:</span>
            <span class="n">parts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">scene_label</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">fold</span><span class="p">:</span>
            <span class="n">parts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;fold&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">fold</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">setup_part</span> <span class="o">==</span> <span class="s1">&#39;train&#39;</span><span class="p">:</span>
            <span class="n">parts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;train&#39;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">setup_part</span> <span class="o">==</span> <span class="s1">&#39;test&#39;</span><span class="p">:</span>
            <span class="n">parts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;test&#39;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">setup_part</span> <span class="o">==</span> <span class="s1">&#39;evaluate&#39;</span><span class="p">:</span>
            <span class="n">parts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;evaluate&#39;</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">parts</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="n">file_extension</span><span class="p">)</span></div>


<div class="viewcode-block" id="AcousticSceneDataset"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.AcousticSceneDataset.html#dcase_framework.datasets.AcousticSceneDataset">[docs]</a><span class="k">class</span> <span class="nc">AcousticSceneDataset</span><span class="p">(</span><span class="n">Dataset</span><span class="p">):</span>
<div class="viewcode-block" id="AcousticSceneDataset.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.AcousticSceneDataset.html#dcase_framework.datasets.AcousticSceneDataset.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">AcousticSceneDataset</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;base class&#39;</span></div></div>


<div class="viewcode-block" id="SoundEventDataset"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.SoundEventDataset.html#dcase_framework.datasets.SoundEventDataset">[docs]</a><span class="k">class</span> <span class="nc">SoundEventDataset</span><span class="p">(</span><span class="n">Dataset</span><span class="p">):</span>
<div class="viewcode-block" id="SoundEventDataset.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.SoundEventDataset.html#dcase_framework.datasets.SoundEventDataset.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">SoundEventDataset</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;base class&#39;</span></div>

<div class="viewcode-block" id="SoundEventDataset.event_label_count"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.SoundEventDataset.event_label_count.html#dcase_framework.datasets.SoundEventDataset.event_label_count">[docs]</a>    <span class="k">def</span> <span class="nf">event_label_count</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Number of unique scene labels in the meta data.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        scene_label : str</span>
<span class="sd">            Scene label</span>
<span class="sd">            Default value &quot;None&quot;</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        scene_label_count : int</span>
<span class="sd">            Number of unique scene labels.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">event_labels</span><span class="p">(</span><span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label</span><span class="p">))</span></div>

<div class="viewcode-block" id="SoundEventDataset.event_labels"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.SoundEventDataset.event_labels.html#dcase_framework.datasets.SoundEventDataset.event_labels">[docs]</a>    <span class="k">def</span> <span class="nf">event_labels</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of unique event labels in the meta data.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        scene_label : str</span>
<span class="sd">            Scene label</span>
<span class="sd">            Default value &quot;None&quot;</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        labels : list</span>
<span class="sd">            List of event labels in alphabetical order.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">scene_label</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">labels</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label</span><span class="p">)</span><span class="o">.</span><span class="n">unique_event_labels</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">labels</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">unique_event_labels</span>

        <span class="n">labels</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">labels</span></div>

<div class="viewcode-block" id="SoundEventDataset.train"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.SoundEventDataset.train.html#dcase_framework.datasets.SoundEventDataset.train">[docs]</a>    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of training items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>
<span class="sd">        scene_label : str</span>
<span class="sd">            Scene label</span>
<span class="sd">            (Default value &quot;None&quot;)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to training set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">scene_label_</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>

                <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span><span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;train&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label_</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
                        <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label_</span>
                    <span class="p">)</span>

                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>

        <span class="k">if</span> <span class="n">scene_label</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label</span><span class="p">]</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="n">data</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span>

            <span class="k">return</span> <span class="n">data</span></div>

<div class="viewcode-block" id="SoundEventDataset.test"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.SoundEventDataset.test.html#dcase_framework.datasets.SoundEventDataset.test">[docs]</a>    <span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of testing items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>
<span class="sd">        scene_label : str</span>
<span class="sd">            Scene label</span>
<span class="sd">            (Default value &quot;None&quot;)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to testing set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">scene_label_</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
                <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
                            <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;test&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label_</span><span class="p">)</span>
                    <span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                <span class="k">else</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
                        <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label_</span>
                    <span class="p">)</span>

                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>

        <span class="k">if</span> <span class="n">scene_label</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label</span><span class="p">]</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="n">data</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span>

            <span class="k">return</span> <span class="n">data</span></div>

    <span class="k">def</span> <span class="nf">eval</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of evaluation items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>
<span class="sd">        scene_label : str</span>
<span class="sd">            Scene label</span>
<span class="sd">            (Default value &quot;None&quot;)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to testing set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">scene_label_</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
                <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
                            <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;test&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label_</span><span class="p">)</span>
                    <span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                <span class="k">else</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
                        <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label_</span>
                    <span class="p">)</span>

                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>

        <span class="k">if</span> <span class="n">scene_label</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label</span><span class="p">]</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="n">data</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_eval</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span>

            <span class="k">return</span> <span class="n">data</span>

    <span class="k">def</span> <span class="nf">train_files</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of training files.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>
<span class="sd">        scene_label : str</span>
<span class="sd">            Scene label</span>
<span class="sd">            (Default value &quot;None&quot;)</span>
<span class="sd">        event_label : str</span>
<span class="sd">            Event label</span>
<span class="sd">            (Default value &quot;None&quot;)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of filenames</span>
<span class="sd">            List containing all files assigned to training set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">train</span><span class="p">(</span><span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="n">event_label</span><span class="p">)</span><span class="o">.</span><span class="n">file_list</span>

    <span class="k">def</span> <span class="nf">test_files</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of testing files.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>
<span class="sd">        scene_label : str</span>
<span class="sd">            Scene label</span>
<span class="sd">            (Default value &quot;None&quot;)</span>
<span class="sd">        event_label : str</span>
<span class="sd">            Event label</span>
<span class="sd">            (Default value &quot;None&quot;)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of filenames</span>
<span class="sd">            List containing all files assigned to testing set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="n">event_label</span><span class="p">)</span><span class="o">.</span><span class="n">file_list</span>

    <span class="k">def</span> <span class="nf">eval_files</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of evaluation files.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>
<span class="sd">        scene_label : str</span>
<span class="sd">            Scene label</span>
<span class="sd">            (Default value &quot;None&quot;)</span>
<span class="sd">        event_label : str</span>
<span class="sd">            Event label</span>
<span class="sd">            (Default value &quot;None&quot;)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of filenames</span>
<span class="sd">            List containing all files assigned to testing set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">eval</span><span class="p">(</span><span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="n">event_label</span><span class="p">)</span><span class="o">.</span><span class="n">file_list</span>

    <span class="k">def</span> <span class="nf">validation_files</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of validation files if they are specified by the dataset. Validation files are always subset of training files.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>
<span class="sd">        scene_label : str</span>
<span class="sd">            Scene label</span>
<span class="sd">            (Default value &quot;None&quot;)</span>
<span class="sd">        event_label : str</span>
<span class="sd">            Event label</span>
<span class="sd">            (Default value &quot;None&quot;)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of filenames</span>
<span class="sd">            List containing all files assigned to training set for given fold.</span>
<span class="sd">            Default value=[]</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="p">[]</span></div>


<span class="k">class</span> <span class="nc">SyntheticSoundEventDataset</span><span class="p">(</span><span class="n">SoundEventDataset</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">SyntheticSoundEventDataset</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;base class&#39;</span>

    <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="c1"># Create the dataset path if does not exist</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">):</span>
            <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">check_filelist</span><span class="p">():</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">download_packages</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">extract</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_save_filelist_hash</span><span class="p">()</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">synthesize</span><span class="p">()</span>

        <span class="k">return</span> <span class="bp">self</span>

    <span class="nd">@before_and_after_function_wrapper</span>
    <span class="k">def</span> <span class="nf">synthesize</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">pass</span>


<div class="viewcode-block" id="AudioTaggingDataset"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.AudioTaggingDataset.html#dcase_framework.datasets.AudioTaggingDataset">[docs]</a><span class="k">class</span> <span class="nc">AudioTaggingDataset</span><span class="p">(</span><span class="n">Dataset</span><span class="p">):</span>
<div class="viewcode-block" id="AudioTaggingDataset.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.AudioTaggingDataset.html#dcase_framework.datasets.AudioTaggingDataset.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">AudioTaggingDataset</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;base class&#39;</span></div></div>


<span class="c1"># =====================================================</span>
<span class="c1"># DCASE 2017</span>
<span class="c1"># =====================================================</span>
<div class="viewcode-block" id="TUTAcousticScenes_2017_DevelopmentSet"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTAcousticScenes_2017_DevelopmentSet.html#dcase_framework.datasets.TUTAcousticScenes_2017_DevelopmentSet">[docs]</a><span class="k">class</span> <span class="nc">TUTAcousticScenes_2017_DevelopmentSet</span><span class="p">(</span><span class="n">AcousticSceneDataset</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;TUT Acoustic scenes 2017 development dataset</span>

<span class="sd">    This dataset is used in DCASE2017 - Task 1, Acoustic scene classification</span>

<span class="sd">    &quot;&quot;&quot;</span>

<div class="viewcode-block" id="TUTAcousticScenes_2017_DevelopmentSet.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTAcousticScenes_2017_DevelopmentSet.html#dcase_framework.datasets.TUTAcousticScenes_2017_DevelopmentSet.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development&#39;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TUTAcousticScenes_2017_DevelopmentSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;acoustic scene&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Annamaria Mesaros, Toni Heittola, and Tuomas Virtanen&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;TUT Acoustic Scenes 2017, development dataset&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Field recording&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Roland Edirol R-09&#39;</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Soundman OKM II Klassik/studio A3 electret microphone&#39;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">4</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.doc.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.doc.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.meta.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.meta.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.error.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.error.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.audio.1.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.audio.1.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.audio.2.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.audio.2.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.audio.3.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.audio.3.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.audio.4.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.audio.4.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.audio.5.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.audio.5.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.audio.6.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.audio.6.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.audio.7.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.audio.7.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.audio.8.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.audio.8.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.audio.9.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.audio.9.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/400515/files/TUT-acoustic-scenes-2017-development.audio.10.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-development.audio.10.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">}</span>
        <span class="p">]</span></div>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;After dataset packages are downloaded and extracted, meta-files are checked.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="n">meta_data</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">fold</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span><span class="p">):</span>
                <span class="c1"># Read train files in</span>
                <span class="n">fold_data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                    <span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;fold&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">fold</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_train.txt&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                <span class="n">fold_data</span> <span class="o">+=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                    <span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;fold&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">fold</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_evaluate.txt&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">fold_data</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">meta_data</span><span class="p">:</span>
                        <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>
                        <span class="n">relative_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">raw_path</span><span class="p">)</span>
                        <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">relative_path</span><span class="p">,</span> <span class="n">raw_filename</span><span class="p">)</span>
                        <span class="n">item</span><span class="p">[</span><span class="s1">&#39;identifier&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">raw_filename</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                        <span class="n">meta_data</span><span class="p">[</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]]</span> <span class="o">=</span> <span class="n">item</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">meta_data</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of training items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to training set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                    <span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;fold&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">fold</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_train.txt&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>
                    <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>
                    <span class="n">location_id</span> <span class="o">=</span> <span class="n">raw_filename</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;identifier&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">location_id</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span></div>


<span class="k">class</span> <span class="nc">TUTAcousticScenes_2017_EvaluationSet</span><span class="p">(</span><span class="n">AcousticSceneDataset</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;TUT Acoustic scenes 2017 evaluation dataset</span>

<span class="sd">    This dataset is used in DCASE2017 - Task 1, Acoustic scene classification</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation&#39;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TUTAcousticScenes_2017_EvaluationSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;acoustic scene&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Annamaria Mesaros, Toni Heittola, and Tuomas Virtanen&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;TUT Acoustic Scenes 2017, development dataset&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Field recording&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Roland Edirol R-09&#39;</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Soundman OKM II Klassik/studio A3 electret microphone&#39;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">1</span>
        <span class="n">source_url</span> <span class="o">=</span> <span class="s1">&#39;https://zenodo.org/record/1040168/files/&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;street&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation.doc.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation.doc.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation.meta.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation.meta.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation.audio.1.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation.audio.1.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation.audio.2.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation.audio.2.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation.audio.3.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation.audio.3.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation.audio.4.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2017-evaluation.audio.4.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
        <span class="p">]</span>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;After dataset packages are downloaded and extracted, meta-files are checked.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;evaluate.txt&#39;</span><span class="p">)):</span>
                <span class="n">meta_data</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">()</span>

                <span class="c1"># Read files in</span>
                <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                    <span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;evaluate.txt&#39;</span><span class="p">)</span>
                <span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                <span class="c1"># Load filename mapping</span>
                <span class="n">map_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;map.txt&#39;</span><span class="p">)</span>
                <span class="n">filename_map</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">map_filename</span><span class="p">):</span>
                    <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">map_filename</span><span class="p">,</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">csv</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span><span class="p">):</span>
                            <span class="n">filename_map</span><span class="p">[</span><span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">row</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">meta_data</span><span class="p">:</span>
                        <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>
                        <span class="n">relative_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">raw_path</span><span class="p">)</span>
                        <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">relative_path</span><span class="p">,</span> <span class="n">raw_filename</span><span class="p">)</span>

                        <span class="c1"># Recover location identifier from ordinal filename</span>
                        <span class="k">if</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="ow">in</span> <span class="n">filename_map</span><span class="p">:</span>
                            <span class="n">item</span><span class="p">[</span><span class="s1">&#39;identifier&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">filename_map</span><span class="p">[</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]])[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>

                        <span class="n">meta_data</span><span class="p">[</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]]</span> <span class="o">=</span> <span class="n">item</span>

                <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">meta_data</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="k">return</span> <span class="p">[]</span>

    <span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of testing items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to testing set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;fold&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">fold</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_test.txt&#39;</span><span class="p">),</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">csv</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span><span class="p">):</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">row</span><span class="p">[</span><span class="mi">0</span><span class="p">])})</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;test.txt&#39;</span><span class="p">),</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">csv</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span><span class="p">):</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">row</span><span class="p">[</span><span class="mi">0</span><span class="p">])})</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span>


<div class="viewcode-block" id="TUTRareSoundEvents_2017_DevelopmentSet"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTRareSoundEvents_2017_DevelopmentSet.html#dcase_framework.datasets.TUTRareSoundEvents_2017_DevelopmentSet">[docs]</a><span class="k">class</span> <span class="nc">TUTRareSoundEvents_2017_DevelopmentSet</span><span class="p">(</span><span class="n">SyntheticSoundEventDataset</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;TUT Acoustic scenes 2017 development dataset</span>

<span class="sd">    This dataset is used in DCASE2017 - Task 2, Rare sound event detection</span>

<span class="sd">    &quot;&quot;&quot;</span>

<div class="viewcode-block" id="TUTRareSoundEvents_2017_DevelopmentSet.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTRareSoundEvents_2017_DevelopmentSet.html#dcase_framework.datasets.TUTRareSoundEvents_2017_DevelopmentSet.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-development&#39;</span><span class="p">)</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;filelisthash_exclude_dirs&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;filelisthash_exclude_dirs&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;generated_data&#39;</span><span class="p">])</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dcase_compatibility</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;dcase_compatibility&#39;</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">synth_parameters</span> <span class="o">=</span> <span class="n">DottedDict</span><span class="p">({</span>
            <span class="s1">&#39;train&#39;</span><span class="p">:</span> <span class="p">{</span>
                <span class="s1">&#39;seed&#39;</span><span class="p">:</span> <span class="mi">42</span><span class="p">,</span>
                <span class="s1">&#39;mixture&#39;</span><span class="p">:</span> <span class="p">{</span>
                    <span class="s1">&#39;fs&#39;</span><span class="p">:</span> <span class="mi">44100</span><span class="p">,</span>
                    <span class="s1">&#39;bitdepth&#39;</span><span class="p">:</span> <span class="mi">24</span><span class="p">,</span>
                    <span class="s1">&#39;length_seconds&#39;</span><span class="p">:</span> <span class="mf">30.0</span><span class="p">,</span>
                    <span class="s1">&#39;anticlipping_factor&#39;</span><span class="p">:</span> <span class="mf">0.2</span><span class="p">,</span>
                <span class="p">},</span>
                <span class="s1">&#39;event_presence_prob&#39;</span><span class="p">:</span> <span class="mf">0.5</span><span class="p">,</span>
                <span class="s1">&#39;mixtures_per_class&#39;</span><span class="p">:</span> <span class="mi">500</span><span class="p">,</span>
                <span class="s1">&#39;ebr_list&#39;</span><span class="p">:</span> <span class="p">[</span><span class="o">-</span><span class="mi">6</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">6</span><span class="p">],</span>
            <span class="p">},</span>
            <span class="s1">&#39;test&#39;</span><span class="p">:</span> <span class="p">{</span>
                <span class="s1">&#39;seed&#39;</span><span class="p">:</span> <span class="mi">42</span><span class="p">,</span>
                <span class="s1">&#39;mixture&#39;</span><span class="p">:</span> <span class="p">{</span>
                    <span class="s1">&#39;fs&#39;</span><span class="p">:</span> <span class="mi">44100</span><span class="p">,</span>
                    <span class="s1">&#39;bitdepth&#39;</span><span class="p">:</span> <span class="mi">24</span><span class="p">,</span>
                    <span class="s1">&#39;length_seconds&#39;</span><span class="p">:</span> <span class="mf">30.0</span><span class="p">,</span>
                    <span class="s1">&#39;anticlipping_factor&#39;</span><span class="p">:</span> <span class="mf">0.2</span><span class="p">,</span>
                <span class="p">},</span>
                <span class="s1">&#39;event_presence_prob&#39;</span><span class="p">:</span> <span class="mf">0.5</span><span class="p">,</span>
                <span class="s1">&#39;mixtures_per_class&#39;</span><span class="p">:</span> <span class="mi">500</span><span class="p">,</span>
                <span class="s1">&#39;ebr_list&#39;</span><span class="p">:</span> <span class="p">[</span><span class="o">-</span><span class="mi">6</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">6</span><span class="p">],</span>
            <span class="p">}</span>
        <span class="p">})</span>

        <span class="c1"># Override synth parameters</span>
        <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;synth_parameters&#39;</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">synth_parameters</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;synth_parameters&#39;</span><span class="p">))</span>

        <span class="c1"># Meta filename depends on synth parameters</span>
        <span class="n">meta_filename</span> <span class="o">=</span> <span class="s1">&#39;meta_&#39;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">synth_parameters</span><span class="o">.</span><span class="n">get_hash_for_path</span><span class="p">()</span><span class="o">+</span><span class="s1">&#39;.txt&#39;</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;meta_filename&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;meta_filename&#39;</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s1">&#39;generated_data&#39;</span><span class="p">,</span> <span class="n">meta_filename</span><span class="p">))</span>

        <span class="c1"># Initialize baseclass</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TUTRareSoundEvents_2017_DevelopmentSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;sound event&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Aleksandr Diment, Annamaria Mesaros, Toni Heittola, and Tuomas Virtanen&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;TUT Rare Sound Events 2017, development dataset&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Synthetic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Unknown&#39;</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Unknown&#39;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">1</span>

        <span class="n">source_url</span> <span class="o">=</span> <span class="s1">&#39;https://zenodo.org/record/401395/files/&#39;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span><span class="o">+</span><span class="s1">&#39;TUT-rare-sound-events-2017-development.doc.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-development.doc.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span><span class="o">+</span><span class="s1">&#39;TUT-rare-sound-events-2017-development.code.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-development.code.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span><span class="o">+</span><span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.1.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.1.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span><span class="o">+</span><span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.2.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.2.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span><span class="o">+</span><span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.3.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.3.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span><span class="o">+</span><span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.4.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.4.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span><span class="o">+</span><span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.5.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.5.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span><span class="o">+</span><span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.6.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.6.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span><span class="o">+</span><span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.7.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.7.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span><span class="o">+</span><span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.8.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_bgs_and_cvsetup.8.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span><span class="o">+</span><span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_events.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-development.source_data_events.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">}</span>
        <span class="p">]</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">event_labels</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of unique event labels in the meta data.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        labels : list</span>
<span class="sd">            List of event labels in alphabetical order.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">labels</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;babycry&#39;</span><span class="p">,</span> <span class="s1">&#39;glassbreak&#39;</span><span class="p">,</span> <span class="s1">&#39;gunshot&#39;</span><span class="p">]</span>
        <span class="n">labels</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">labels</span>

    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of training items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>
<span class="sd">        event_label : str</span>
<span class="sd">            Event label</span>
<span class="sd">            Default value &quot;None&quot;</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to training set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>

            <span class="k">for</span> <span class="n">event_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_labels</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">event_label_</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>

                <span class="k">if</span> <span class="n">fold</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="n">params_hash</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">synth_parameters</span><span class="o">.</span><span class="n">get_hash_for_path</span><span class="p">(</span><span class="s1">&#39;train&#39;</span><span class="p">)</span>
                    <span class="n">mixture_meta_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                        <span class="s1">&#39;generated_data&#39;</span><span class="p">,</span>
                        <span class="s1">&#39;mixtures_devtrain_&#39;</span> <span class="o">+</span> <span class="n">params_hash</span><span class="p">,</span>
                        <span class="s1">&#39;meta&#39;</span>
                    <span class="p">)</span>

                    <span class="n">event_list_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="n">mixture_meta_path</span><span class="p">,</span>
                        <span class="s1">&#39;event_list_devtrain_&#39;</span> <span class="o">+</span> <span class="n">event_label_</span> <span class="o">+</span> <span class="s1">&#39;.csv&#39;</span>
                    <span class="p">)</span>

                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="n">event_list_filename</span><span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                <span class="k">elif</span> <span class="n">fold</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="n">params_hash</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">synth_parameters</span><span class="o">.</span><span class="n">get_hash_for_path</span><span class="p">(</span><span class="s1">&#39;train&#39;</span><span class="p">)</span>
                    <span class="n">mixture_meta_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                        <span class="s1">&#39;generated_data&#39;</span><span class="p">,</span>
                        <span class="s1">&#39;mixtures_devtrain_&#39;</span> <span class="o">+</span> <span class="n">params_hash</span><span class="p">,</span>
                        <span class="s1">&#39;meta&#39;</span>
                    <span class="p">)</span>

                    <span class="n">event_list_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="n">mixture_meta_path</span><span class="p">,</span>
                        <span class="s1">&#39;event_list_devtrain_&#39;</span> <span class="o">+</span> <span class="n">event_label_</span> <span class="o">+</span> <span class="s1">&#39;.csv&#39;</span>
                    <span class="p">)</span>

                    <span class="c1"># Load train files</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="n">event_list_filename</span><span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                    <span class="n">params_hash</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">synth_parameters</span><span class="o">.</span><span class="n">get_hash_for_path</span><span class="p">(</span><span class="s1">&#39;test&#39;</span><span class="p">)</span>
                    <span class="n">mixture_meta_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                        <span class="s1">&#39;generated_data&#39;</span><span class="p">,</span>
                        <span class="s1">&#39;mixtures_devtest_&#39;</span> <span class="o">+</span> <span class="n">params_hash</span><span class="p">,</span>
                        <span class="s1">&#39;meta&#39;</span>
                    <span class="p">)</span>
                    <span class="n">event_list_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="n">mixture_meta_path</span><span class="p">,</span>
                        <span class="s1">&#39;event_list_devtest_&#39;</span> <span class="o">+</span> <span class="n">event_label_</span> <span class="o">+</span> <span class="s1">&#39;.csv&#39;</span>
                    <span class="p">)</span>

                    <span class="c1"># Load test files</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span> <span class="o">+=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="n">event_list_filename</span><span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>

        <span class="k">if</span> <span class="n">event_label</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">event_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_labels</span><span class="p">:</span>
                <span class="n">data</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span>

            <span class="k">return</span> <span class="n">data</span>

    <span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of testing items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>
<span class="sd">        event_label : str</span>
<span class="sd">            Event label</span>
<span class="sd">            Default value &quot;None&quot;</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to testing set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">event_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_labels</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">event_label_</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
                <span class="k">if</span> <span class="n">fold</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="n">params_hash</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">synth_parameters</span><span class="o">.</span><span class="n">get_hash_for_path</span><span class="p">(</span><span class="s1">&#39;test&#39;</span><span class="p">)</span>
                    <span class="n">mixture_meta_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                        <span class="s1">&#39;generated_data&#39;</span><span class="p">,</span>
                        <span class="s1">&#39;mixtures_devtest_&#39;</span> <span class="o">+</span> <span class="n">params_hash</span><span class="p">,</span>
                        <span class="s1">&#39;meta&#39;</span>
                    <span class="p">)</span>

                    <span class="n">event_list_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">mixture_meta_path</span><span class="p">,</span> <span class="s1">&#39;event_list_devtest_&#39;</span> <span class="o">+</span> <span class="n">event_label_</span> <span class="o">+</span> <span class="s1">&#39;.csv&#39;</span><span class="p">)</span>

                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="n">event_list_filename</span>
                    <span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                <span class="k">elif</span> <span class="n">fold</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="n">params_hash</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">synth_parameters</span><span class="o">.</span><span class="n">get_hash_for_path</span><span class="p">(</span><span class="s1">&#39;train&#39;</span><span class="p">)</span>
                    <span class="n">mixture_meta_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                        <span class="s1">&#39;generated_data&#39;</span><span class="p">,</span>
                        <span class="s1">&#39;mixtures_devtrain_&#39;</span> <span class="o">+</span> <span class="n">params_hash</span><span class="p">,</span>
                        <span class="s1">&#39;meta&#39;</span>
                    <span class="p">)</span>

                    <span class="n">event_list_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="n">mixture_meta_path</span><span class="p">,</span>
                        <span class="s1">&#39;event_list_devtrain_&#39;</span> <span class="o">+</span> <span class="n">event_label_</span> <span class="o">+</span> <span class="s1">&#39;.csv&#39;</span>
                    <span class="p">)</span>

                    <span class="c1"># Load train files</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="n">event_list_filename</span>
                    <span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                    <span class="n">params_hash</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">synth_parameters</span><span class="o">.</span><span class="n">get_hash_for_path</span><span class="p">(</span><span class="s1">&#39;test&#39;</span><span class="p">)</span>
                    <span class="n">mixture_meta_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                        <span class="s1">&#39;generated_data&#39;</span><span class="p">,</span>
                        <span class="s1">&#39;mixtures_devtest_&#39;</span> <span class="o">+</span> <span class="n">params_hash</span><span class="p">,</span>
                        <span class="s1">&#39;meta&#39;</span>
                    <span class="p">)</span>

                    <span class="n">event_list_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="n">mixture_meta_path</span><span class="p">,</span>
                        <span class="s1">&#39;event_list_devtest_&#39;</span> <span class="o">+</span> <span class="n">event_label_</span> <span class="o">+</span> <span class="s1">&#39;.csv&#39;</span>
                    <span class="p">)</span>

                    <span class="c1"># Load test files</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span> <span class="o">+=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="n">event_list_filename</span>
                    <span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>

        <span class="k">if</span> <span class="n">event_label</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">event_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_labels</span><span class="p">:</span>
                <span class="n">data</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span>

            <span class="k">return</span> <span class="n">data</span>

    <span class="nd">@before_and_after_function_wrapper</span>
    <span class="k">def</span> <span class="nf">synthesize</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">subset_map</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;train&#39;</span><span class="p">:</span> <span class="s1">&#39;devtrain&#39;</span><span class="p">,</span>
                      <span class="s1">&#39;test&#39;</span><span class="p">:</span> <span class="s1">&#39;devtest&#39;</span><span class="p">}</span>

        <span class="n">background_audio_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="s1">&#39;source_data&#39;</span><span class="p">,</span> <span class="s1">&#39;bgs&#39;</span><span class="p">)</span>
        <span class="n">event_audio_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="s1">&#39;source_data&#39;</span><span class="p">,</span> <span class="s1">&#39;events&#39;</span><span class="p">)</span>
        <span class="n">cv_setup_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="s1">&#39;source_data&#39;</span><span class="p">,</span> <span class="s1">&#39;cv_setup&#39;</span><span class="p">)</span>

        <span class="n">set_progress</span> <span class="o">=</span> <span class="n">tqdm</span><span class="p">([</span><span class="s1">&#39;train&#39;</span><span class="p">,</span> <span class="s1">&#39;test&#39;</span><span class="p">],</span>
                            <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &lt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Set&#39;</span><span class="p">),</span>
                            <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                            <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                            <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                            <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">subset_label</span> <span class="ow">in</span> <span class="n">set_progress</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">log_system_progress</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;  </span><span class="si">{title:&lt;15s}</span><span class="s1"> [</span><span class="si">{subset_label:&lt;30s}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">title</span><span class="o">=</span><span class="s1">&#39;Set &#39;</span><span class="p">,</span>
                    <span class="n">subset_label</span><span class="o">=</span><span class="n">subset_label</span><span class="p">)</span>
                <span class="p">)</span>

            <span class="n">subset_name_on_disk</span> <span class="o">=</span> <span class="n">subset_map</span><span class="p">[</span><span class="n">subset_label</span><span class="p">]</span>

            <span class="n">background_meta</span> <span class="o">=</span> <span class="n">ParameterListFile</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">cv_setup_path</span><span class="p">,</span> <span class="s1">&#39;bgs_&#39;</span> <span class="o">+</span> <span class="n">subset_name_on_disk</span> <span class="o">+</span> <span class="s1">&#39;.yaml&#39;</span><span class="p">))</span>
            <span class="n">event_meta</span> <span class="o">=</span> <span class="n">ParameterFile</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span>
                <span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">cv_setup_path</span><span class="p">,</span> <span class="s1">&#39;events_&#39;</span> <span class="o">+</span> <span class="n">subset_name_on_disk</span> <span class="o">+</span> <span class="s1">&#39;.yaml&#39;</span><span class="p">)</span>
            <span class="p">)</span>

            <span class="n">params</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">synth_parameters</span><span class="o">.</span><span class="n">get_path</span><span class="p">(</span><span class="n">subset_label</span><span class="p">)</span>
            <span class="n">params_hash</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">synth_parameters</span><span class="o">.</span><span class="n">get_hash_for_path</span><span class="p">(</span><span class="n">subset_label</span><span class="p">)</span>

            <span class="n">r</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">RandomState</span><span class="p">(</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;seed&#39;</span><span class="p">,</span> <span class="mi">42</span><span class="p">))</span>

            <span class="n">mixture_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                <span class="s1">&#39;generated_data&#39;</span><span class="p">,</span>
                <span class="s1">&#39;mixtures_&#39;</span> <span class="o">+</span> <span class="n">subset_name_on_disk</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="n">params_hash</span>
            <span class="p">)</span>

            <span class="n">mixture_audio_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                <span class="s1">&#39;generated_data&#39;</span><span class="p">,</span>
                <span class="s1">&#39;mixtures_&#39;</span> <span class="o">+</span> <span class="n">subset_name_on_disk</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="n">params_hash</span><span class="p">,</span>
                <span class="s1">&#39;audio&#39;</span>
            <span class="p">)</span>

            <span class="n">mixture_meta_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                <span class="s1">&#39;generated_data&#39;</span><span class="p">,</span>
                <span class="s1">&#39;mixtures_&#39;</span> <span class="o">+</span> <span class="n">subset_name_on_disk</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="n">params_hash</span><span class="p">,</span>
                <span class="s1">&#39;meta&#39;</span>
            <span class="p">)</span>

            <span class="c1"># Make sure folder exists</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">mixture_path</span><span class="p">):</span>
                <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">mixture_path</span><span class="p">)</span>

            <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">mixture_audio_path</span><span class="p">):</span>
                <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">mixture_audio_path</span><span class="p">)</span>

            <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">mixture_meta_path</span><span class="p">):</span>
                <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">mixture_meta_path</span><span class="p">)</span>

            <span class="n">class_progress</span> <span class="o">=</span> <span class="n">tqdm</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">event_labels</span><span class="p">,</span>
                                  <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &lt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Class&#39;</span><span class="p">),</span>
                                  <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                                  <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                  <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                                  <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span><span class="p">)</span>

            <span class="k">for</span> <span class="n">class_label</span> <span class="ow">in</span> <span class="n">class_progress</span><span class="p">:</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">log_system_progress</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;  </span><span class="si">{title:&lt;15s}</span><span class="s1"> [</span><span class="si">{class_label:&lt;30s}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">title</span><span class="o">=</span><span class="s1">&#39;Class &#39;</span><span class="p">,</span>
                        <span class="n">class_label</span><span class="o">=</span><span class="n">class_label</span><span class="p">)</span>
                    <span class="p">)</span>

                <span class="n">mixture_recipes_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                    <span class="n">mixture_meta_path</span><span class="p">,</span>
                    <span class="s1">&#39;mixture_recipes_&#39;</span> <span class="o">+</span> <span class="n">subset_name_on_disk</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="n">class_label</span> <span class="o">+</span> <span class="s1">&#39;.yaml&#39;</span>
                <span class="p">)</span>

                <span class="c1"># Generate recipes if not exists</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">mixture_recipes_filename</span><span class="p">):</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_generate_mixture_recipes</span><span class="p">(</span>
                        <span class="n">params</span><span class="o">=</span><span class="n">params</span><span class="p">,</span>
                        <span class="n">class_label</span><span class="o">=</span><span class="n">class_label</span><span class="p">,</span>
                        <span class="n">subset</span><span class="o">=</span><span class="n">subset_name_on_disk</span><span class="p">,</span>
                        <span class="n">mixture_recipes_filename</span><span class="o">=</span><span class="n">mixture_recipes_filename</span><span class="p">,</span>
                        <span class="n">background_meta</span><span class="o">=</span><span class="n">background_meta</span><span class="p">,</span>
                        <span class="n">event_meta</span><span class="o">=</span><span class="n">event_meta</span><span class="p">[</span><span class="n">class_label</span><span class="p">],</span>
                        <span class="n">background_audio_path</span><span class="o">=</span><span class="n">background_audio_path</span><span class="p">,</span>
                        <span class="n">event_audio_path</span><span class="o">=</span><span class="n">event_audio_path</span><span class="p">,</span>
                        <span class="n">r</span><span class="o">=</span><span class="n">r</span>
                    <span class="p">)</span>

                <span class="n">mixture_meta</span> <span class="o">=</span> <span class="n">ParameterListFile</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">mixture_recipes_filename</span><span class="p">)</span>

                <span class="c1"># Generate mixture signals</span>
                <span class="n">item_progress</span> <span class="o">=</span> <span class="n">tqdm</span><span class="p">(</span><span class="n">mixture_meta</span><span class="p">,</span>
                                     <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &lt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Generate mixture&#39;</span><span class="p">),</span>
                                     <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                                     <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                     <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                                     <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span><span class="p">)</span>

                <span class="k">for</span> <span class="n">item_id</span><span class="p">,</span> <span class="n">item</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">item_progress</span><span class="p">):</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">log_system_progress</span><span class="p">:</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;  </span><span class="si">{title:&lt;15s}</span><span class="s1"> [</span><span class="si">{item_id:d}</span><span class="s1">/</span><span class="si">{total:d}</span><span class="s1">] </span><span class="si">{file:&lt;30s}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">title</span><span class="o">=</span><span class="s1">&#39;Generate mixture &#39;</span><span class="p">,</span>
                            <span class="n">item_id</span><span class="o">=</span><span class="n">item_id</span><span class="p">,</span>
                            <span class="n">total</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">item_progress</span><span class="p">),</span>
                            <span class="n">file</span><span class="o">=</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;mixture_audio_filename&#39;</span><span class="p">])</span>
                        <span class="p">)</span>

                    <span class="n">mixture_file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">mixture_audio_path</span><span class="p">,</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;mixture_audio_filename&#39;</span><span class="p">])</span>

                    <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">mixture_file</span><span class="p">):</span>
                        <span class="n">mixture</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_synthesize_mixture</span><span class="p">(</span>
                            <span class="n">mixture_recipe</span><span class="o">=</span><span class="n">item</span><span class="p">,</span>
                            <span class="n">params</span><span class="o">=</span><span class="n">params</span><span class="p">,</span>
                            <span class="n">background_audio_path</span><span class="o">=</span><span class="n">background_audio_path</span><span class="p">,</span>
                            <span class="n">event_audio_path</span><span class="o">=</span><span class="n">event_audio_path</span>
                        <span class="p">)</span>

                        <span class="n">audio_container</span> <span class="o">=</span> <span class="n">AudioFile</span><span class="p">(</span>
                            <span class="n">data</span><span class="o">=</span><span class="n">mixture</span><span class="p">,</span>
                            <span class="n">fs</span><span class="o">=</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;mixture&#39;</span><span class="p">][</span><span class="s1">&#39;fs&#39;</span><span class="p">]</span>
                        <span class="p">)</span>

                        <span class="n">audio_container</span><span class="o">.</span><span class="n">save</span><span class="p">(</span>
                            <span class="n">filename</span><span class="o">=</span><span class="n">mixture_file</span><span class="p">,</span>
                            <span class="n">bitdepth</span><span class="o">=</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;mixture&#39;</span><span class="p">][</span><span class="s1">&#39;bitdepth&#39;</span><span class="p">]</span>
                        <span class="p">)</span>

                <span class="c1"># Generate event lists</span>
                <span class="n">event_list_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                    <span class="n">mixture_meta_path</span><span class="p">,</span>
                    <span class="s1">&#39;event_list_&#39;</span> <span class="o">+</span> <span class="n">subset_name_on_disk</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="n">class_label</span> <span class="o">+</span> <span class="s1">&#39;.csv&#39;</span>
                <span class="p">)</span>

                <span class="n">event_list</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">event_list_filename</span><span class="p">)</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">event_list</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
                    <span class="n">item_progress</span> <span class="o">=</span> <span class="n">tqdm</span><span class="p">(</span><span class="n">mixture_meta</span><span class="p">,</span>
                                         <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &lt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Event list&#39;</span><span class="p">),</span>
                                         <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                                         <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                         <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                                         <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span><span class="p">)</span>
                    <span class="k">for</span> <span class="n">item_id</span><span class="p">,</span> <span class="n">item</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">item_progress</span><span class="p">):</span>
                        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">log_system_progress</span><span class="p">:</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;  </span><span class="si">{title:&lt;15s}</span><span class="s1"> [</span><span class="si">{item_id:d}</span><span class="s1">/</span><span class="si">{total:d}</span><span class="s1">] </span><span class="si">{file:&lt;30s}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                                <span class="n">title</span><span class="o">=</span><span class="s1">&#39;Event list &#39;</span><span class="p">,</span>
                                <span class="n">item_id</span><span class="o">=</span><span class="n">item_id</span><span class="p">,</span>
                                <span class="n">total</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">item_progress</span><span class="p">),</span>
                                <span class="n">file</span><span class="o">=</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;mixture_audio_filename&#39;</span><span class="p">])</span>
                            <span class="p">)</span>

                        <span class="n">event_list_item</span> <span class="o">=</span> <span class="p">{</span>
                            <span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                                <span class="s1">&#39;generated_data&#39;</span><span class="p">,</span>
                                <span class="s1">&#39;mixtures_&#39;</span> <span class="o">+</span> <span class="n">subset_name_on_disk</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="n">params_hash</span><span class="p">,</span>
                                <span class="s1">&#39;audio&#39;</span><span class="p">,</span>
                                <span class="n">item</span><span class="p">[</span><span class="s1">&#39;mixture_audio_filename&#39;</span><span class="p">]</span>
                            <span class="p">),</span>
                        <span class="p">}</span>
                        <span class="k">if</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;event_present&#39;</span><span class="p">]:</span>
                            <span class="n">event_list_item</span><span class="p">[</span><span class="s1">&#39;event_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;event_class&#39;</span><span class="p">]</span>
                            <span class="n">event_list_item</span><span class="p">[</span><span class="s1">&#39;event_onset&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;event_start_in_mixture_seconds&#39;</span><span class="p">])</span>
                            <span class="n">event_list_item</span><span class="p">[</span><span class="s1">&#39;event_offset&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;event_start_in_mixture_seconds&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;event_length_seconds&#39;</span><span class="p">])</span>

                        <span class="n">event_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">MetaDataItem</span><span class="p">(</span><span class="n">event_list_item</span><span class="p">))</span>
                    <span class="n">event_list</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>

                <span class="n">mixture_parameters</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">mixture_path</span><span class="p">,</span> <span class="s1">&#39;parameters.yaml&#39;</span><span class="p">)</span>
                <span class="c1"># Save parameters</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">mixture_parameters</span><span class="p">):</span>
                    <span class="n">ParameterFile</span><span class="p">(</span><span class="n">params</span><span class="p">)</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">mixture_parameters</span><span class="p">)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="c1"># Collect meta data</span>
            <span class="n">meta_data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">class_label</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_labels</span><span class="p">:</span>

                <span class="k">for</span> <span class="n">subset_label</span><span class="p">,</span> <span class="n">subset_name_on_disk</span> <span class="ow">in</span> <span class="n">iteritems</span><span class="p">(</span><span class="n">subset_map</span><span class="p">):</span>
                    <span class="n">params_hash</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">synth_parameters</span><span class="o">.</span><span class="n">get_hash_for_path</span><span class="p">(</span><span class="n">subset_label</span><span class="p">)</span>
                    <span class="n">mixture_meta_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                        <span class="s1">&#39;generated_data&#39;</span><span class="p">,</span>
                        <span class="s1">&#39;mixtures_&#39;</span> <span class="o">+</span> <span class="n">subset_name_on_disk</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="n">params_hash</span><span class="p">,</span>
                        <span class="s1">&#39;meta&#39;</span>
                    <span class="p">)</span>

                    <span class="n">event_list_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="n">mixture_meta_path</span><span class="p">,</span>
                        <span class="s1">&#39;event_list_&#39;</span> <span class="o">+</span> <span class="n">subset_name_on_disk</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="n">class_label</span> <span class="o">+</span> <span class="s1">&#39;.csv&#39;</span>
                    <span class="p">)</span>

                    <span class="n">meta_data</span> <span class="o">+=</span> <span class="n">MetaDataContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">event_list_filename</span><span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">meta_data</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dcase_compatibility</span><span class="p">:</span>
            <span class="c1"># Run dataset patcher if it have not been run before</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filename</span><span class="o">+</span><span class="s1">&#39;_old_dontuse&#39;</span><span class="p">):</span>
                <span class="c1"># Create init so we can call functions</span>
                <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT_Rare_sound_events_mixture_synthesizer&#39;</span><span class="p">,</span> <span class="s1">&#39;__init__.py&#39;</span><span class="p">)):</span>
                    <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT_Rare_sound_events_mixture_synthesizer&#39;</span><span class="p">,</span> <span class="s1">&#39;__init__.py&#39;</span><span class="p">),</span> <span class="s1">&#39;a&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

                <span class="c1"># Patch dataset</span>
                <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT_Rare_sound_events_mixture_synthesizer&#39;</span><span class="p">))</span>
                <span class="kn">from</span> <span class="nn">dcase2017_task2_patcher</span> <span class="k">import</span> <span class="n">main</span> <span class="k">as</span> <span class="n">patcher</span>
                <span class="n">patcher</span><span class="p">(</span><span class="n">path_to_dataset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">)</span>

                <span class="c1"># Load modified meta information</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">_generate_mixture_recipes</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">params</span><span class="p">,</span> <span class="n">subset</span><span class="p">,</span> <span class="n">class_label</span><span class="p">,</span> <span class="n">mixture_recipes_filename</span><span class="p">,</span> <span class="n">background_meta</span><span class="p">,</span>
                                  <span class="n">event_meta</span><span class="p">,</span> <span class="n">background_audio_path</span><span class="p">,</span> <span class="n">event_audio_path</span><span class="p">,</span> <span class="n">r</span><span class="p">):</span>

        <span class="k">def</span> <span class="nf">get_event_amplitude_scaling_factor</span><span class="p">(</span><span class="n">signal</span><span class="p">,</span> <span class="n">noise</span><span class="p">,</span> <span class="n">target_snr_db</span><span class="p">):</span>
            <span class="sd">&quot;&quot;&quot;Get amplitude scaling factor</span>

<span class="sd">            Different lengths for signal and noise allowed: longer noise assumed to be stationary enough,</span>
<span class="sd">            and rmse is calculated over the whole signal</span>

<span class="sd">            Parameters</span>
<span class="sd">            ----------</span>
<span class="sd">            signal : numpy.ndarray</span>
<span class="sd">            noise : numpy.ndarray</span>
<span class="sd">            target_snr_db : float</span>

<span class="sd">            Returns</span>
<span class="sd">            -------</span>
<span class="sd">            float &gt; 0.0</span>
<span class="sd">            &quot;&quot;&quot;</span>

            <span class="k">def</span> <span class="nf">rmse</span><span class="p">(</span><span class="n">y</span><span class="p">):</span>
                <span class="sd">&quot;&quot;&quot;RMSE&quot;&quot;&quot;</span>
                <span class="k">return</span> <span class="n">numpy</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="o">**</span> <span class="mi">2</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">keepdims</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span>

            <span class="n">original_sn_rmse_ratio</span> <span class="o">=</span> <span class="n">rmse</span><span class="p">(</span><span class="n">signal</span><span class="p">)</span> <span class="o">/</span> <span class="n">rmse</span><span class="p">(</span><span class="n">noise</span><span class="p">)</span>
            <span class="n">target_sn_rmse_ratio</span> <span class="o">=</span> <span class="mi">10</span> <span class="o">**</span> <span class="p">(</span><span class="n">target_snr_db</span> <span class="o">/</span> <span class="nb">float</span><span class="p">(</span><span class="mi">20</span><span class="p">))</span>
            <span class="n">signal_scaling_factor</span> <span class="o">=</span> <span class="n">target_sn_rmse_ratio</span> <span class="o">/</span> <span class="n">original_sn_rmse_ratio</span>
            <span class="k">return</span> <span class="n">signal_scaling_factor</span>

        <span class="c1"># Internal variables</span>
        <span class="n">fs</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;mixture&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">,</span> <span class="mi">44100</span><span class="p">))</span>

        <span class="n">current_class_events</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="c1"># Inject fields to meta data</span>
        <span class="k">for</span> <span class="n">event</span> <span class="ow">in</span> <span class="n">event_meta</span><span class="p">:</span>
            <span class="n">event</span><span class="p">[</span><span class="s1">&#39;classname&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">class_label</span>
            <span class="n">event</span><span class="p">[</span><span class="s1">&#39;audio_filepath&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">class_label</span><span class="p">,</span> <span class="n">event</span><span class="p">[</span><span class="s1">&#39;audio_filename&#39;</span><span class="p">])</span>
            <span class="n">event</span><span class="p">[</span><span class="s1">&#39;length_seconds&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">event</span><span class="p">[</span><span class="s1">&#39;segment&#39;</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">current_class_events</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">event</span><span class="p">)</span>

        <span class="c1"># Randomize order of event and background</span>
        <span class="n">events</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">choice</span><span class="p">(</span><span class="n">current_class_events</span><span class="p">,</span>
                          <span class="nb">int</span><span class="p">(</span><span class="nb">round</span><span class="p">(</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;mixtures_per_class&#39;</span><span class="p">)</span> <span class="o">*</span> <span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;event_presence_prob&#39;</span><span class="p">))))</span>
        <span class="n">bgs</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">choice</span><span class="p">(</span><span class="n">background_meta</span><span class="p">,</span> <span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;mixtures_per_class&#39;</span><span class="p">))</span>

        <span class="c1"># Event presence flags</span>
        <span class="n">event_presence_flags</span> <span class="o">=</span> <span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">hstack</span><span class="p">((</span><span class="n">numpy</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">events</span><span class="p">)),</span> <span class="n">numpy</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">bgs</span><span class="p">)</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">events</span><span class="p">)))))</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">bool</span><span class="p">)</span>
        <span class="n">event_presence_flags</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">permutation</span><span class="p">(</span><span class="n">event_presence_flags</span><span class="p">)</span>

        <span class="c1"># Event instance IDs, by default event id set to nan: no event. fill it later with actual event ids when needed</span>
        <span class="n">event_instance_ids</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">nan</span> <span class="o">*</span> <span class="n">numpy</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">bgs</span><span class="p">))</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">int</span><span class="p">)</span>
        <span class="n">event_instance_ids</span><span class="p">[</span><span class="n">event_presence_flags</span><span class="p">]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">events</span><span class="p">))</span>

        <span class="c1"># Randomize event position inside background</span>
        <span class="k">for</span> <span class="n">event</span> <span class="ow">in</span> <span class="n">events</span><span class="p">:</span>
            <span class="n">event</span><span class="p">[</span><span class="s1">&#39;offset_seconds&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;mixture&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;length_seconds&#39;</span><span class="p">)</span> <span class="o">-</span> <span class="n">event</span><span class="p">[</span><span class="s1">&#39;length_seconds&#39;</span><span class="p">])</span> <span class="o">*</span> <span class="n">r</span><span class="o">.</span><span class="n">rand</span><span class="p">()</span>

        <span class="c1"># Get offsets for all mixtures, If no event present, use nans</span>
        <span class="n">event_offsets_seconds</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">nan</span> <span class="o">*</span> <span class="n">numpy</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">bgs</span><span class="p">))</span>
        <span class="n">event_offsets_seconds</span><span class="p">[</span><span class="n">event_presence_flags</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">event</span><span class="p">[</span><span class="s1">&#39;offset_seconds&#39;</span><span class="p">]</span> <span class="k">for</span> <span class="n">event</span> <span class="ow">in</span> <span class="n">events</span><span class="p">]</span>

        <span class="c1"># Double-check that we didn&#39;t shuffle things wrongly: check that the offset never exceeds bg_len-event_len</span>
        <span class="n">checker</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">offset</span><span class="p">,</span> <span class="n">event_instance_id</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">event_offsets_seconds</span><span class="p">[</span><span class="n">event_presence_flags</span><span class="p">],</span> <span class="n">event_instance_ids</span><span class="p">[</span><span class="n">event_presence_flags</span><span class="p">]):</span>
            <span class="n">checker</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">offset</span> <span class="o">+</span> <span class="n">events</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">event_instance_id</span><span class="p">)][</span><span class="s1">&#39;length_seconds&#39;</span><span class="p">])</span>

        <span class="k">assert</span> <span class="n">numpy</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">checker</span><span class="p">))</span> <span class="o">&lt;</span> <span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;mixture&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;length_seconds&#39;</span><span class="p">)</span>

        <span class="c1"># Target EBRs</span>
        <span class="n">target_ebrs</span> <span class="o">=</span> <span class="o">-</span><span class="n">numpy</span><span class="o">.</span><span class="n">inf</span> <span class="o">*</span> <span class="n">numpy</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">bgs</span><span class="p">))</span>
        <span class="n">target_ebrs</span><span class="p">[</span><span class="n">event_presence_flags</span><span class="p">]</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">choice</span><span class="p">(</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;ebr_list&#39;</span><span class="p">),</span> <span class="n">size</span><span class="o">=</span><span class="n">numpy</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">event_presence_flags</span><span class="p">))</span>

        <span class="c1"># For recipes, we got to provide amplitude scaling factors instead of SNRs: the latter are more ambiguous</span>
        <span class="c1"># so, go through files, measure levels, calculate scaling factors</span>
        <span class="n">mixture_recipes</span> <span class="o">=</span> <span class="n">ParameterListFile</span><span class="p">()</span>
        <span class="k">for</span> <span class="n">mixture_id</span><span class="p">,</span> <span class="p">(</span><span class="n">bg</span><span class="p">,</span> <span class="n">event_presence_flag</span><span class="p">,</span> <span class="n">event_start_in_mixture_seconds</span><span class="p">,</span> <span class="n">ebr</span><span class="p">,</span> <span class="n">event_instance_id</span><span class="p">)</span> <span class="ow">in</span> <span class="n">tqdm</span><span class="p">(</span>
                <span class="nb">enumerate</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">bgs</span><span class="p">,</span> <span class="n">event_presence_flags</span><span class="p">,</span> <span class="n">event_offsets_seconds</span><span class="p">,</span> <span class="n">target_ebrs</span><span class="p">,</span> <span class="n">event_instance_ids</span><span class="p">)),</span>
                <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &lt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Generate recipe&#39;</span><span class="p">),</span>
                <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                <span class="n">total</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">bgs</span><span class="p">),</span>
                <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span><span class="p">):</span>

            <span class="c1"># Read the bgs and events, measure their energies, find amplitude scaling factors</span>
            <span class="n">mixture_recipe</span> <span class="o">=</span> <span class="p">{</span>
                <span class="s1">&#39;bg_path&#39;</span><span class="p">:</span> <span class="n">bg</span><span class="p">[</span><span class="s1">&#39;filepath&#39;</span><span class="p">],</span>
                <span class="s1">&#39;bg_classname&#39;</span><span class="p">:</span> <span class="n">bg</span><span class="p">[</span><span class="s1">&#39;classname&#39;</span><span class="p">],</span>
                <span class="s1">&#39;event_present&#39;</span><span class="p">:</span> <span class="nb">bool</span><span class="p">(</span><span class="n">event_presence_flag</span><span class="p">),</span>
                <span class="s1">&#39;ebr&#39;</span><span class="p">:</span> <span class="nb">float</span><span class="p">(</span><span class="n">ebr</span><span class="p">)</span>
            <span class="p">}</span>

            <span class="k">if</span> <span class="n">event_presence_flag</span><span class="p">:</span>
                <span class="c1"># We have an event assigned</span>

                <span class="k">assert</span> <span class="ow">not</span> <span class="n">numpy</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">event_instance_id</span><span class="p">)</span>

                <span class="c1"># Load background and event audio in</span>
                <span class="n">bg_audio</span><span class="p">,</span> <span class="n">fs_bg</span> <span class="o">=</span> <span class="n">AudioFile</span><span class="p">(</span><span class="n">fs</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;mixture&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">(</span>
                    <span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">background_audio_path</span><span class="p">,</span> <span class="n">bg</span><span class="p">[</span><span class="s1">&#39;filepath&#39;</span><span class="p">])</span>
                <span class="p">)</span>

                <span class="n">event_audio</span><span class="p">,</span> <span class="n">fs_event</span> <span class="o">=</span> <span class="n">AudioFile</span><span class="p">(</span><span class="n">fs</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;mixture&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">(</span>
                    <span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">event_audio_path</span><span class="p">,</span> <span class="n">events</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">event_instance_id</span><span class="p">)][</span><span class="s1">&#39;audio_filepath&#39;</span><span class="p">])</span>
                <span class="p">)</span>

                <span class="k">assert</span> <span class="n">fs_bg</span> <span class="o">==</span> <span class="n">fs_event</span><span class="p">,</span> <span class="s1">&#39;Fs mismatch! Expected resampling taken place already&#39;</span>

                <span class="c1"># Segment onset and offset in samples</span>
                <span class="n">segment_start_samples</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">events</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">event_instance_id</span><span class="p">)][</span><span class="s1">&#39;segment&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="n">fs</span><span class="p">)</span>
                <span class="n">segment_end_samples</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">events</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">event_instance_id</span><span class="p">)][</span><span class="s1">&#39;segment&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">fs</span><span class="p">)</span>

                <span class="c1"># Cut event audio</span>
                <span class="n">event_audio</span> <span class="o">=</span> <span class="n">event_audio</span><span class="p">[</span><span class="n">segment_start_samples</span><span class="p">:</span><span class="n">segment_end_samples</span><span class="p">]</span>

                <span class="c1"># Let&#39;s calculate the levels of bgs also at the location of the event only</span>
                <span class="n">eventful_part_of_bg</span> <span class="o">=</span> <span class="n">bg_audio</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">event_start_in_mixture_seconds</span> <span class="o">*</span> <span class="n">fs</span><span class="p">):</span><span class="nb">int</span><span class="p">(</span><span class="n">event_start_in_mixture_seconds</span> <span class="o">*</span> <span class="n">fs</span> <span class="o">+</span> <span class="nb">len</span><span class="p">(</span><span class="n">event_audio</span><span class="p">))]</span>

                <span class="k">if</span> <span class="n">eventful_part_of_bg</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Background segment having an event has zero length.&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span>
                    <span class="p">)</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

                <span class="n">scaling_factor</span> <span class="o">=</span> <span class="n">get_event_amplitude_scaling_factor</span><span class="p">(</span><span class="n">event_audio</span><span class="p">,</span> <span class="n">eventful_part_of_bg</span><span class="p">,</span> <span class="n">target_snr_db</span><span class="o">=</span><span class="n">ebr</span><span class="p">)</span>

                <span class="c1"># Store information</span>
                <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;event_path&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">events</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">event_instance_id</span><span class="p">)][</span><span class="s1">&#39;audio_filepath&#39;</span><span class="p">]</span>
                <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;event_class&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">events</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">event_instance_id</span><span class="p">)][</span><span class="s1">&#39;classname&#39;</span><span class="p">]</span>
                <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;event_start_in_mixture_seconds&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">event_start_in_mixture_seconds</span><span class="p">)</span>
                <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;event_length_seconds&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">events</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">event_instance_id</span><span class="p">)][</span><span class="s1">&#39;length_seconds&#39;</span><span class="p">])</span>
                <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;scaling_factor&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">scaling_factor</span><span class="p">)</span>
                <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;segment_start_seconds&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">events</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">event_instance_id</span><span class="p">)][</span><span class="s1">&#39;segment&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
                <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;segment_end_seconds&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">events</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">event_instance_id</span><span class="p">)][</span><span class="s1">&#39;segment&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>

            <span class="c1"># Generate mixture filename</span>
            <span class="n">mixing_param_hash</span> <span class="o">=</span> <span class="n">hashlib</span><span class="o">.</span><span class="n">md5</span><span class="p">(</span><span class="n">yaml</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">mixture_recipe</span><span class="p">)</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">hexdigest</span><span class="p">()</span>
            <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;mixture_audio_filename&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;mixture&#39;</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="n">subset</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="n">class_label</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="si">%03d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">mixture_id</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="n">mixing_param_hash</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">default_audio_extension</span>

            <span class="c1"># Generate mixture annotation</span>
            <span class="k">if</span> <span class="n">event_presence_flag</span><span class="p">:</span>
                <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;annotation_string&#39;</span><span class="p">]</span> <span class="o">=</span> \
                    <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;mixture_audio_filename&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span> <span class="o">+</span> \
                    <span class="s2">&quot;</span><span class="si">{0:.14f}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;event_start_in_mixture_seconds&#39;</span><span class="p">])</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span> <span class="o">+</span> \
                    <span class="s2">&quot;</span><span class="si">{0:.14f}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;event_start_in_mixture_seconds&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;event_length_seconds&#39;</span><span class="p">])</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span> <span class="o">+</span> \
                    <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;event_class&#39;</span><span class="p">]</span>

            <span class="k">else</span><span class="p">:</span>
                <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;annotation_string&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;mixture_audio_filename&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="s1">&#39;None&#39;</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\t</span><span class="s1">0</span><span class="se">\t</span><span class="s1">30&#39;</span>

            <span class="c1"># Store mixture recipe</span>
            <span class="n">mixture_recipes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mixture_recipe</span><span class="p">)</span>

        <span class="c1"># Save mixture recipe</span>
        <span class="n">mixture_recipes</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">mixture_recipes_filename</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_synthesize_mixture</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mixture_recipe</span><span class="p">,</span> <span class="n">params</span><span class="p">,</span> <span class="n">background_audio_path</span><span class="p">,</span> <span class="n">event_audio_path</span><span class="p">):</span>
        <span class="n">background_audiofile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">background_audio_path</span><span class="p">,</span> <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;bg_path&#39;</span><span class="p">])</span>

        <span class="c1"># Load background audio</span>
        <span class="n">bg_audio_data</span><span class="p">,</span> <span class="n">fs_bg</span> <span class="o">=</span> <span class="n">AudioFile</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">background_audiofile</span><span class="p">,</span>
                                                <span class="n">fs</span><span class="o">=</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;mixture&#39;</span><span class="p">][</span><span class="s1">&#39;fs&#39;</span><span class="p">],</span>
                                                <span class="n">mono</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;event_present&#39;</span><span class="p">]:</span>
            <span class="n">event_audiofile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">event_audio_path</span><span class="p">,</span> <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;event_path&#39;</span><span class="p">])</span>

            <span class="c1"># Load event audio</span>
            <span class="n">event_audio_data</span><span class="p">,</span> <span class="n">fs_event</span> <span class="o">=</span> <span class="n">AudioFile</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">event_audiofile</span><span class="p">,</span>
                                                          <span class="n">fs</span><span class="o">=</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;mixture&#39;</span><span class="p">][</span><span class="s1">&#39;fs&#39;</span><span class="p">],</span>
                                                          <span class="n">mono</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

            <span class="k">if</span> <span class="n">fs_bg</span> <span class="o">!=</span> <span class="n">fs_event</span><span class="p">:</span>
                <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Sampling frequency mismatch. Material should be resampled.&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span>
                <span class="p">)</span>

                <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

            <span class="c1"># Slice event audio</span>
            <span class="n">segment_start_samples</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;segment_start_seconds&#39;</span><span class="p">]</span> <span class="o">*</span> <span class="n">params</span><span class="p">[</span><span class="s1">&#39;mixture&#39;</span><span class="p">][</span><span class="s1">&#39;fs&#39;</span><span class="p">])</span>
            <span class="n">segment_end_samples</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;segment_end_seconds&#39;</span><span class="p">]</span> <span class="o">*</span> <span class="n">params</span><span class="p">[</span><span class="s1">&#39;mixture&#39;</span><span class="p">][</span><span class="s1">&#39;fs&#39;</span><span class="p">])</span>
            <span class="n">event_audio_data</span> <span class="o">=</span> <span class="n">event_audio_data</span><span class="p">[</span><span class="n">segment_start_samples</span><span class="p">:</span><span class="n">segment_end_samples</span><span class="p">]</span>

            <span class="n">event_start_in_mixture_samples</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;event_start_in_mixture_seconds&#39;</span><span class="p">]</span> <span class="o">*</span> <span class="n">params</span><span class="p">[</span><span class="s1">&#39;mixture&#39;</span><span class="p">][</span><span class="s1">&#39;fs&#39;</span><span class="p">])</span>
            <span class="n">scaling_factor</span> <span class="o">=</span> <span class="n">mixture_recipe</span><span class="p">[</span><span class="s1">&#39;scaling_factor&#39;</span><span class="p">]</span>

            <span class="c1"># Mix event into background audio</span>
            <span class="n">mixture</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mix</span><span class="p">(</span><span class="n">bg_audio_data</span><span class="o">=</span><span class="n">bg_audio_data</span><span class="p">,</span>
                                <span class="n">event_audio_data</span><span class="o">=</span><span class="n">event_audio_data</span><span class="p">,</span>
                                <span class="n">event_start_in_mixture_samples</span><span class="o">=</span><span class="n">event_start_in_mixture_samples</span><span class="p">,</span>
                                <span class="n">scaling_factor</span><span class="o">=</span><span class="n">scaling_factor</span><span class="p">,</span>
                                <span class="n">magic_anticlipping_factor</span><span class="o">=</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;mixture&#39;</span><span class="p">][</span><span class="s1">&#39;anticlipping_factor&#39;</span><span class="p">])</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">mixture</span> <span class="o">=</span> <span class="n">params</span><span class="p">[</span><span class="s1">&#39;mixture&#39;</span><span class="p">][</span><span class="s1">&#39;anticlipping_factor&#39;</span><span class="p">]</span> <span class="o">*</span> <span class="n">bg_audio_data</span>

        <span class="k">return</span> <span class="n">mixture</span>

    <span class="k">def</span> <span class="nf">_mix</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">bg_audio_data</span><span class="p">,</span> <span class="n">event_audio_data</span><span class="p">,</span> <span class="n">event_start_in_mixture_samples</span><span class="p">,</span> <span class="n">scaling_factor</span><span class="p">,</span> <span class="n">magic_anticlipping_factor</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Mix numpy arrays of background and event audio (mono, non-matching lengths supported, sampling frequency</span>
<span class="sd">        better be the same, no operation in terms of seconds is performed though)</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        bg_audio_data : numpy.array</span>
<span class="sd">        event_audio_data : numpy.array</span>
<span class="sd">        event_start_in_mixture_samples : float</span>
<span class="sd">        scaling_factor : float</span>
<span class="sd">        magic_anticlipping_factor : float</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        numpy.array</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># Store current event audio max value</span>
        <span class="n">event_audio_original_max</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">event_audio_data</span><span class="p">))</span>

        <span class="c1"># Adjust SNRs</span>
        <span class="n">event_audio_data</span> <span class="o">*=</span> <span class="n">scaling_factor</span>

        <span class="c1"># Check that the offset is not too long</span>
        <span class="n">longest_possible_offset</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">bg_audio_data</span><span class="p">)</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">event_audio_data</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">event_start_in_mixture_samples</span> <span class="o">&gt;</span> <span class="n">longest_possible_offset</span><span class="p">:</span>
            <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Wrongly generated event offset: event tries to go outside the boundaries of the bg.&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
            <span class="k">raise</span> <span class="ne">AssertionError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

        <span class="c1"># Measure how much to pad from the right</span>
        <span class="n">tail_length</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">bg_audio_data</span><span class="p">)</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">event_audio_data</span><span class="p">)</span> <span class="o">-</span> <span class="n">event_start_in_mixture_samples</span>

        <span class="c1"># Pad zeros at the beginning of event signal</span>
        <span class="n">padded_event</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">pad</span><span class="p">(</span><span class="n">event_audio_data</span><span class="p">,</span>
                                 <span class="n">pad_width</span><span class="o">=</span><span class="p">((</span><span class="n">event_start_in_mixture_samples</span><span class="p">,</span> <span class="n">tail_length</span><span class="p">)),</span>
                                 <span class="n">mode</span><span class="o">=</span><span class="s1">&#39;constant&#39;</span><span class="p">,</span>
                                 <span class="n">constant_values</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="nb">len</span><span class="p">(</span><span class="n">padded_event</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">bg_audio_data</span><span class="p">):</span>
            <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Mixing yielded a signal of different length than bg! Should not happen.&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span>
            <span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
            <span class="k">raise</span> <span class="ne">AssertionError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

        <span class="n">mixture</span> <span class="o">=</span> <span class="n">magic_anticlipping_factor</span> <span class="o">*</span> <span class="p">(</span><span class="n">padded_event</span> <span class="o">+</span> <span class="n">bg_audio_data</span><span class="p">)</span>

        <span class="c1"># Also nice to make sure that we did not introduce clipping</span>
        <span class="k">if</span> <span class="n">numpy</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">mixture</span><span class="p">))</span> <span class="o">&gt;=</span> <span class="mi">1</span><span class="p">:</span>
            <span class="n">normalisation_factor</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">/</span> <span class="nb">float</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">mixture</span><span class="p">)))</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Attention! Had to normalise the mixture by [</span><span class="si">{factor}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">factor</span><span class="o">=</span><span class="n">normalisation_factor</span><span class="p">))</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;I.e. bg max: </span><span class="si">{bg_max:2.4f}</span><span class="s1">, event max: </span><span class="si">{event_max:2.4f}</span><span class="s1">, sum max: </span><span class="si">{sum_max:2.4f}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">bg_max</span><span class="o">=</span><span class="n">numpy</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">bg_audio_data</span><span class="p">)),</span>
                <span class="n">event_max</span><span class="o">=</span><span class="n">numpy</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">padded_event</span><span class="p">)),</span>
                <span class="n">sum_max</span><span class="o">=</span><span class="n">numpy</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">mixture</span><span class="p">)))</span>
            <span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;The scaling factor for the event was [</span><span class="si">{factor}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">factor</span><span class="o">=</span><span class="n">scaling_factor</span><span class="p">))</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;The event before scaling was max [</span><span class="si">{max}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">max</span><span class="o">=</span><span class="n">event_audio_original_max</span><span class="p">))</span>
            <span class="n">mixture</span> <span class="o">/=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">mixture</span><span class="p">))</span>

        <span class="k">return</span> <span class="n">mixture</span></div>


<span class="k">class</span> <span class="nc">TUTRareSoundEvents_2017_EvaluationSet</span><span class="p">(</span><span class="n">SyntheticSoundEventDataset</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;TUT Acoustic scenes 2017 evaluation dataset</span>

<span class="sd">    This dataset is used in DCASE2017 - Task 2, Rare sound event detection</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-evaluation&#39;</span><span class="p">)</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;filelisthash_exclude_dirs&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;filelisthash_exclude_dirs&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;generated_data&#39;</span><span class="p">])</span>

        <span class="c1"># Initialize baseclass</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TUTRareSoundEvents_2017_EvaluationSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">reference_data_present</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;sound event&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Aleksandr Diment, Annamaria Mesaros, Toni Heittola, and Tuomas Virtanen&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;TUT Rare Sound Events 2017, evaluation dataset&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Synthetic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Unknown&#39;</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Unknown&#39;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">1</span>

        <span class="n">source_url</span> <span class="o">=</span> <span class="s1">&#39;https://zenodo.org/record/1160455/files/&#39;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-rare-sound-events-2017-evaluation.mixture_data.1.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-evaluation.mixture_data.1.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-rare-sound-events-2017-evaluation.mixture_data.2.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-evaluation.mixture_data.2.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-rare-sound-events-2017-evaluation.mixture_data.3.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-evaluation.mixture_data.3.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-rare-sound-events-2017-evaluation.mixture_data.4.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-evaluation.mixture_data.4.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-rare-sound-events-2017-evaluation.mixture_data.5.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-rare-sound-events-2017-evaluation.mixture_data.5.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>

        <span class="p">]</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">event_labels</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of unique event labels in the meta data.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        labels : list</span>
<span class="sd">            List of event labels in alphabetical order.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">labels</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;babycry&#39;</span><span class="p">,</span> <span class="s1">&#39;glassbreak&#39;</span><span class="p">,</span> <span class="s1">&#39;gunshot&#39;</span><span class="p">]</span>
        <span class="n">labels</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">labels</span>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;After dataset packages are downloaded and extracted, meta-files are checked.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">reference_data_present</span><span class="p">:</span>
            <span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{name}</span><span class="s1">: Meta file not found [</span><span class="si">{filename}</span><span class="s1">]&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filename</span>
            <span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
            <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="k">return</span> <span class="p">[]</span>

    <span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">event_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of testing items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>
<span class="sd">        event_label : str</span>
<span class="sd">            Event label</span>
<span class="sd">            Default value &quot;None&quot;</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to testing set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">event_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_labels</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">event_label_</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>

                <span class="k">if</span> <span class="n">fold</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">audio_files</span><span class="p">:</span>
                        <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
                        <span class="n">relative_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">raw_path</span><span class="p">)</span>
                        <span class="n">base_filename</span><span class="p">,</span> <span class="n">file_extension</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">raw_filename</span><span class="p">)</span>
                        <span class="k">if</span> <span class="n">event_label_</span> <span class="ow">in</span> <span class="n">base_filename</span><span class="p">:</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">MetaDataItem</span><span class="p">({</span><span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">relative_path</span><span class="p">,</span> <span class="n">raw_filename</span><span class="p">)}))</span>

        <span class="k">if</span> <span class="n">event_label</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">event_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_labels</span><span class="p">:</span>
                <span class="n">data</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">event_label_</span><span class="p">]</span>

            <span class="k">return</span> <span class="n">data</span>


<div class="viewcode-block" id="TUTSoundEvents_2017_DevelopmentSet"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTSoundEvents_2017_DevelopmentSet.html#dcase_framework.datasets.TUTSoundEvents_2017_DevelopmentSet">[docs]</a><span class="k">class</span> <span class="nc">TUTSoundEvents_2017_DevelopmentSet</span><span class="p">(</span><span class="n">SoundEventDataset</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;TUT Sound events 2017 development dataset</span>

<span class="sd">    This dataset is used in DCASE2017 - Task 3, Sound event detection in real life audio</span>

<span class="sd">    &quot;&quot;&quot;</span>

<div class="viewcode-block" id="TUTSoundEvents_2017_DevelopmentSet.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTSoundEvents_2017_DevelopmentSet.html#dcase_framework.datasets.TUTSoundEvents_2017_DevelopmentSet.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2017-development&#39;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TUTSoundEvents_2017_DevelopmentSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;sound event&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Annamaria Mesaros, Toni Heittola, and Tuomas Virtanen&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;TUT Sound Events 2016, development dataset&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45759&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Field recording&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Roland Edirol R-09&#39;</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Soundman OKM II Klassik/studio A3 electret microphone&#39;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">4</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;street&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/814831/files/TUT-sound-events-2017-development.doc.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2017-development.doc.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/814831/files/TUT-sound-events-2017-development.meta.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2017-development.meta.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/814831/files/TUT-sound-events-2017-development.audio.1.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2017-development.audio.1.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/814831/files/TUT-sound-events-2017-development.audio.2.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2017-development.audio.2.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
        <span class="p">]</span></div>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;After dataset packages are downloaded and extracted, meta-files are checked.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="n">meta_data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">audio_files</span><span class="p">:</span>
                <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
                <span class="n">relative_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">raw_path</span><span class="p">)</span>
                <span class="n">scene_label</span> <span class="o">=</span> <span class="n">relative_path</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span>
                <span class="n">base_filename</span><span class="p">,</span> <span class="n">file_extension</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">raw_filename</span><span class="p">)</span>
                <span class="n">annotation_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                    <span class="n">relative_path</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;meta&#39;</span><span class="p">),</span>
                    <span class="n">base_filename</span> <span class="o">+</span> <span class="s1">&#39;.ann&#39;</span>
                <span class="p">)</span>

                <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">annotation_filename</span><span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">relative_path</span><span class="p">,</span> <span class="n">raw_filename</span><span class="p">)</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;scene_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">scene_label</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;identifier&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">raw_filename</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;source_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;mixture&#39;</span>

                <span class="n">meta_data</span> <span class="o">+=</span> <span class="n">data</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">meta_data</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of training items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>
<span class="sd">        scene_label : str</span>
<span class="sd">            Scene label</span>
<span class="sd">            Default value &quot;None&quot;</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to training set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">scene_label_</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>

                <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
                            <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;train&#39;</span><span class="p">,</span>
                            <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label_</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

                <span class="k">else</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
                        <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label_</span>
                    <span class="p">)</span>

                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>
                    <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;identifier&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">raw_filename</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;source_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;mixture&#39;</span>

        <span class="k">if</span> <span class="n">scene_label</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="n">data</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span>

            <span class="k">return</span> <span class="n">data</span></div>


<span class="k">class</span> <span class="nc">TUTSoundEvents_2017_EvaluationSet</span><span class="p">(</span><span class="n">SoundEventDataset</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;TUT Sound events 2017 evaluation dataset</span>

<span class="sd">    This dataset is used in DCASE2017 - Task 3, Sound event detection in real life audio</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2017-evaluation&#39;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TUTSoundEvents_2017_EvaluationSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;sound event&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Annamaria Mesaros, Toni Heittola, and Tuomas Virtanen&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;TUT Sound Events 2016, development dataset&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45759&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Field recording&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Roland Edirol R-09&#39;</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Soundman OKM II Klassik/studio A3 electret microphone&#39;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">1</span>
        <span class="n">source_url</span> <span class="o">=</span> <span class="s1">&#39;https://zenodo.org/record/1040179/files/&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;street&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-sound-events-2017-evaluation.doc.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2017-evaluation.doc.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-sound-events-2017-evaluation.meta.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2017-evaluation.meta.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">source_url</span> <span class="o">+</span> <span class="s1">&#39;TUT-sound-events-2017-evaluation.audio.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2017-evaluation.audio.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
        <span class="p">]</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">scene_labels</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">labels</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;street&#39;</span><span class="p">]</span>
        <span class="n">labels</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">labels</span>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;After dataset packages are downloaded and extracted, meta-files are checked.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">reference_data_present</span><span class="p">:</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
                <span class="n">meta_data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
                <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">audio_files</span><span class="p">:</span>
                    <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
                    <span class="n">relative_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">raw_path</span><span class="p">)</span>
                    <span class="n">scene_label</span> <span class="o">=</span> <span class="n">relative_path</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span>
                    <span class="n">base_filename</span><span class="p">,</span> <span class="n">file_extension</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">raw_filename</span><span class="p">)</span>
                    <span class="n">annotation_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="n">relative_path</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;meta&#39;</span><span class="p">),</span>
                                                       <span class="n">base_filename</span> <span class="o">+</span> <span class="s1">&#39;.ann&#39;</span><span class="p">)</span>
                    <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">annotation_filename</span><span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
                    <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
                        <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">relative_path</span><span class="p">,</span> <span class="n">raw_filename</span><span class="p">)</span>
                        <span class="n">item</span><span class="p">[</span><span class="s1">&#39;scene_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">scene_label</span>
                        <span class="n">item</span><span class="p">[</span><span class="s1">&#39;identifier&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">raw_filename</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                        <span class="n">item</span><span class="p">[</span><span class="s1">&#39;source_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;mixture&#39;</span>

                    <span class="n">meta_data</span> <span class="o">+=</span> <span class="n">data</span>
                <span class="n">meta_data</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="k">return</span> <span class="p">[]</span>

    <span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">scene_label_</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>

                <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
                            <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;test&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label_</span><span class="p">)</span>
                    <span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
                            <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;test&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label_</span><span class="p">)</span>
                    <span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

        <span class="k">if</span> <span class="n">scene_label</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="n">data</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span>

            <span class="k">return</span> <span class="n">data</span>


<span class="k">class</span> <span class="nc">DCASE2017_Task4tagging_DevelopmentSet</span><span class="p">(</span><span class="n">SoundEventDataset</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;DCASE 2017 Large-scale weakly supervised sound event detection for smart cars</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;DCASE2017-task4-development&#39;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DCASE2017_Task4tagging_DevelopmentSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;audio tagging&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Benjamin Elizalde, Rohan Badlani, Ankit Shah, Emmanuel Vincent, Bhiksha Raj&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;Task 4 Large-scale weakly supervised sound event detection for smart cars&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="s1">&#39;https://github.com/ankitshah009/Task-4-Large-scale-weakly-supervised-sound-event-detection-for-smart-cars&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Field recording&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">1</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">default_audio_extension</span> <span class="o">=</span> <span class="s1">&#39;flac&#39;</span>

        <span class="n">github_url</span> <span class="o">=</span> <span class="s1">&#39;https://raw.githubusercontent.com/ankitshah009/Task-4-Large-scale-weakly-supervised-sound-event-detection-for-smart-cars/master/&#39;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">github_url</span> <span class="o">+</span> <span class="s1">&#39;training_set.csv&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;training_set.csv&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">github_url</span> <span class="o">+</span> <span class="s1">&#39;testing_set.csv&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;testing_set.csv&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">github_url</span> <span class="o">+</span> <span class="s1">&#39;groundtruth_weak_label_training_set.csv&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;groundtruth_weak_label_training_set.csv&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">github_url</span> <span class="o">+</span> <span class="s1">&#39;groundtruth_weak_label_testing_set.csv&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;groundtruth_weak_label_testing_set.csv&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">github_url</span> <span class="o">+</span> <span class="s1">&#39;APACHE_LICENSE.txt&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;APACHE_LICENSE.txt&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">github_url</span> <span class="o">+</span> <span class="s1">&#39;README.txt&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;README.txt&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">github_url</span> <span class="o">+</span> <span class="s1">&#39;sound_event_list_17_classes.txt&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;sound_event_list_17_classes.txt&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="n">github_url</span> <span class="o">+</span> <span class="s1">&#39;groundtruth_strong_label_testing_set.csv&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;groundtruth_strong_label_testing_set.csv&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">}</span>
        <span class="p">]</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">scene_labels</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">labels</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;youtube&#39;</span><span class="p">]</span>
        <span class="n">labels</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">labels</span>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="kn">import</span> <span class="nn">csv</span>
        <span class="kn">from</span> <span class="nn">httplib</span> <span class="k">import</span> <span class="n">BadStatusLine</span>
        <span class="kn">from</span> <span class="nn">dcase_framework.files</span> <span class="k">import</span> <span class="n">AudioFile</span>

        <span class="k">def</span> <span class="nf">progress_hook</span><span class="p">(</span><span class="n">t</span><span class="p">):</span>
            <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            Wraps tqdm instance. Don&#39;t forget to close() or __exit__()</span>
<span class="sd">            the tqdm instance once you&#39;re done with it (easiest using `with` syntax).</span>
<span class="sd">            &quot;&quot;&quot;</span>

            <span class="k">def</span> <span class="nf">inner</span><span class="p">(</span><span class="n">total</span><span class="p">,</span> <span class="n">recvd</span><span class="p">,</span> <span class="n">ratio</span><span class="p">,</span> <span class="n">rate</span><span class="p">,</span> <span class="n">eta</span><span class="p">):</span>
                <span class="n">t</span><span class="o">.</span><span class="n">total</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">total</span> <span class="o">/</span> <span class="mf">1024.0</span><span class="p">)</span>
                <span class="n">t</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">recvd</span> <span class="o">/</span> <span class="mf">1024.0</span><span class="p">))</span>

            <span class="k">return</span> <span class="n">inner</span>

        <span class="c1"># Collect file ids</span>
        <span class="n">files</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;testing_set.csv&#39;</span><span class="p">),</span> <span class="s1">&#39;rb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">csv_file</span><span class="p">:</span>
            <span class="n">csv_reader</span> <span class="o">=</span> <span class="n">csv</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">csv_file</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;,&#39;</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">csv_reader</span><span class="p">:</span>
                <span class="n">files</span><span class="o">.</span><span class="n">append</span><span class="p">({</span>
                    <span class="s1">&#39;query_id&#39;</span><span class="p">:</span> <span class="n">row</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
                    <span class="s1">&#39;segment_start&#39;</span><span class="p">:</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span>
                    <span class="s1">&#39;segment_end&#39;</span><span class="p">:</span> <span class="n">row</span><span class="p">[</span><span class="mi">2</span><span class="p">]}</span>
                <span class="p">)</span>

        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;training_set.csv&#39;</span><span class="p">),</span> <span class="s1">&#39;rb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">csv_file</span><span class="p">:</span>
            <span class="n">csv_reader</span> <span class="o">=</span> <span class="n">csv</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">csv_file</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;,&#39;</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">csv_reader</span><span class="p">:</span>
                <span class="n">files</span><span class="o">.</span><span class="n">append</span><span class="p">({</span>
                    <span class="s1">&#39;query_id&#39;</span><span class="p">:</span> <span class="n">row</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
                    <span class="s1">&#39;segment_start&#39;</span><span class="p">:</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span>
                    <span class="s1">&#39;segment_end&#39;</span><span class="p">:</span> <span class="n">row</span><span class="p">[</span><span class="mi">2</span><span class="p">]}</span>
                <span class="p">)</span>

        <span class="c1"># Make sure audio directory exists</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">)):</span>
            <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">))</span>

        <span class="n">file_progress</span> <span class="o">=</span> <span class="n">tqdm</span><span class="p">(</span><span class="n">files</span><span class="p">,</span>
                             <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &lt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Files&#39;</span><span class="p">),</span>
                             <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                             <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                             <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                             <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span><span class="p">)</span>

        <span class="n">non_existing_videos</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="c1"># Check that audio files exists</span>
        <span class="k">for</span> <span class="n">file_data</span> <span class="ow">in</span> <span class="n">file_progress</span><span class="p">:</span>
            <span class="n">audio_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                                          <span class="s1">&#39;audio&#39;</span><span class="p">,</span>
                                          <span class="s1">&#39;Y</span><span class="si">{query_id}</span><span class="s1">_</span><span class="si">{segment_start}</span><span class="s1">_</span><span class="si">{segment_end}</span><span class="s1">.</span><span class="si">{extension}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                                              <span class="n">query_id</span><span class="o">=</span><span class="n">file_data</span><span class="p">[</span><span class="s1">&#39;query_id&#39;</span><span class="p">],</span>
                                              <span class="n">segment_start</span><span class="o">=</span><span class="n">file_data</span><span class="p">[</span><span class="s1">&#39;segment_start&#39;</span><span class="p">],</span>
                                              <span class="n">segment_end</span><span class="o">=</span><span class="n">file_data</span><span class="p">[</span><span class="s1">&#39;segment_end&#39;</span><span class="p">],</span>
                                              <span class="n">extension</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">default_audio_extension</span>
                                          <span class="p">)</span>
                                          <span class="p">)</span>

            <span class="c1"># Download segment if it does not exists</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">audio_filename</span><span class="p">):</span>
                <span class="kn">import</span> <span class="nn">pafy</span>

                <span class="c1">#</span>
                <span class="k">try</span><span class="p">:</span>
                    <span class="c1"># Access youtube video and get best quality audio stream</span>
                    <span class="n">youtube_audio</span> <span class="o">=</span> <span class="n">pafy</span><span class="o">.</span><span class="n">new</span><span class="p">(</span>
                        <span class="n">url</span><span class="o">=</span><span class="s1">&#39;https://www.youtube.com/watch?v=</span><span class="si">{query_id}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">query_id</span><span class="o">=</span><span class="n">file_data</span><span class="p">[</span><span class="s1">&#39;query_id&#39;</span><span class="p">]),</span>
                        <span class="n">basic</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                        <span class="n">gdata</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                        <span class="n">size</span><span class="o">=</span><span class="kc">False</span>
                    <span class="p">)</span><span class="o">.</span><span class="n">getbestaudio</span><span class="p">()</span>

                    <span class="c1"># Get temp file</span>
                    <span class="n">tmp_file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;tmp_file.</span><span class="si">{extension}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">extension</span><span class="o">=</span><span class="n">youtube_audio</span><span class="o">.</span><span class="n">extension</span><span class="p">)</span>
                                            <span class="p">)</span>

                    <span class="c1"># Create download progress bar</span>
                    <span class="n">download_progress_bar</span> <span class="o">=</span> <span class="n">tqdm</span><span class="p">(</span>
                        <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &lt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Download youtube item &#39;</span><span class="p">),</span>
                        <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                        <span class="n">unit</span><span class="o">=</span><span class="s1">&#39;B&#39;</span><span class="p">,</span>
                        <span class="n">unit_scale</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                        <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                        <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                        <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span>
                    <span class="p">)</span>

                    <span class="c1"># Download audio</span>
                    <span class="n">youtube_audio</span><span class="o">.</span><span class="n">download</span><span class="p">(</span>
                        <span class="n">filepath</span><span class="o">=</span><span class="n">tmp_file</span><span class="p">,</span>
                        <span class="n">quiet</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                        <span class="n">callback</span><span class="o">=</span><span class="n">progress_hook</span><span class="p">(</span><span class="n">download_progress_bar</span><span class="p">)</span>
                    <span class="p">)</span>

                    <span class="c1"># Close progress bar</span>
                    <span class="n">download_progress_bar</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

                    <span class="c1"># Create audio processing progress bar</span>
                    <span class="n">audio_processing_progress_bar</span> <span class="o">=</span> <span class="n">tqdm</span><span class="p">(</span>
                        <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{0: &lt;25s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Processing &#39;</span><span class="p">),</span>
                        <span class="n">initial</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
                        <span class="n">total</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span>
                        <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span>
                        <span class="n">leave</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                        <span class="n">disable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">disable_progress_bar</span><span class="p">,</span>
                        <span class="n">ascii</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">use_ascii_progress_bar</span>
                    <span class="p">)</span>

                    <span class="c1"># Load audio</span>
                    <span class="n">audio_file</span> <span class="o">=</span> <span class="n">AudioFile</span><span class="p">()</span>
                    <span class="n">audio_file</span><span class="o">.</span><span class="n">load</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="n">tmp_file</span><span class="p">,</span>
                        <span class="n">mono</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                        <span class="n">fs</span><span class="o">=</span><span class="mi">44100</span><span class="p">,</span>
                        <span class="n">res_type</span><span class="o">=</span><span class="s1">&#39;kaiser_best&#39;</span><span class="p">,</span>
                        <span class="n">start</span><span class="o">=</span><span class="nb">float</span><span class="p">(</span><span class="n">file_data</span><span class="p">[</span><span class="s1">&#39;segment_start&#39;</span><span class="p">]),</span>
                        <span class="n">stop</span><span class="o">=</span><span class="nb">float</span><span class="p">(</span><span class="n">file_data</span><span class="p">[</span><span class="s1">&#39;segment_end&#39;</span><span class="p">])</span>
                    <span class="p">)</span>
                    <span class="n">audio_processing_progress_bar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>

                    <span class="c1"># Save the segment</span>
                    <span class="n">audio_file</span><span class="o">.</span><span class="n">save</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="n">audio_filename</span><span class="p">,</span>
                        <span class="n">bitdepth</span><span class="o">=</span><span class="mi">16</span>
                    <span class="p">)</span>
                    <span class="n">audio_processing_progress_bar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>

                    <span class="c1"># Remove temporal file</span>
                    <span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">tmp_file</span><span class="p">)</span>
                    <span class="n">audio_processing_progress_bar</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

                <span class="k">except</span> <span class="p">(</span><span class="ne">IOError</span><span class="p">,</span> <span class="n">BadStatusLine</span><span class="p">)</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
                    <span class="c1"># Store files with errors</span>
                    <span class="n">file_data</span><span class="p">[</span><span class="s1">&#39;error&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">message</span><span class="p">)</span>
                    <span class="n">non_existing_videos</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">file_data</span><span class="p">)</span>

                <span class="k">except</span> <span class="p">(</span><span class="ne">KeyboardInterrupt</span><span class="p">,</span> <span class="ne">SystemExit</span><span class="p">):</span>
                    <span class="c1"># Remove temporal file and current audio file.</span>
                    <span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">tmp_file</span><span class="p">)</span>
                    <span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">audio_filename</span><span class="p">)</span>
                    <span class="k">raise</span>

        <span class="n">log_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;item_access_error.log&#39;</span><span class="p">)</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">log_filename</span><span class="p">,</span> <span class="s1">&#39;wb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">csv_file</span><span class="p">:</span>
            <span class="n">csv_writer</span> <span class="o">=</span> <span class="n">csv</span><span class="o">.</span><span class="n">writer</span><span class="p">(</span><span class="n">csv_file</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;,&#39;</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">non_existing_videos</span><span class="p">:</span>
                <span class="n">csv_writer</span><span class="o">.</span><span class="n">writerow</span><span class="p">(</span>
                    <span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;query_id&#39;</span><span class="p">],</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;error&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">,</span> <span class="s1">&#39; &#39;</span><span class="p">))</span>
                <span class="p">)</span>

        <span class="c1"># Make sure evaluation_setup directory exists</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_folder</span><span class="p">)):</span>
            <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_folder</span><span class="p">))</span>

        <span class="c1"># Check that evaluation setup exists</span>
        <span class="n">evaluation_setup_exists</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="n">train_filename</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
            <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;train&#39;</span><span class="p">,</span>
            <span class="n">fold</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
            <span class="n">scene_label</span><span class="o">=</span><span class="s1">&#39;youtube&#39;</span><span class="p">,</span>
            <span class="n">file_extension</span><span class="o">=</span><span class="s1">&#39;txt&#39;</span>
        <span class="p">)</span>

        <span class="n">test_filename</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
            <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;test&#39;</span><span class="p">,</span>
            <span class="n">fold</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
            <span class="n">scene_label</span><span class="o">=</span><span class="s1">&#39;youtube&#39;</span><span class="p">,</span>
            <span class="n">file_extension</span><span class="o">=</span><span class="s1">&#39;txt&#39;</span>
        <span class="p">)</span>

        <span class="n">evaluate_filename</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
            <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;evaluate&#39;</span><span class="p">,</span>
            <span class="n">fold</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
            <span class="n">scene_label</span><span class="o">=</span><span class="s1">&#39;youtube&#39;</span><span class="p">,</span>
            <span class="n">file_extension</span><span class="o">=</span><span class="s1">&#39;txt&#39;</span>
        <span class="p">)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">train_filename</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">test_filename</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span>
                <span class="n">evaluate_filename</span><span class="p">):</span>
            <span class="n">evaluation_setup_exists</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="c1"># Evaluation setup was not found generate</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">evaluation_setup_exists</span><span class="p">:</span>
            <span class="n">fold</span> <span class="o">=</span> <span class="mi">1</span>

            <span class="n">train_meta</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">MetaDataContainer</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span>
                    <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;groundtruth_weak_label_training_set.csv&#39;</span><span class="p">)):</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s1">&#39;flac&#39;</span><span class="p">):</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;Y&#39;</span> <span class="o">+</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])[</span>
                        <span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">default_audio_extension</span><span class="p">)</span>
                <span class="c1"># Set scene label</span>
                <span class="n">item</span><span class="p">[</span><span class="s1">&#39;scene_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;youtube&#39;</span>

                <span class="c1"># Translate event onset and offset, weak labels</span>
                <span class="n">item</span><span class="p">[</span><span class="s1">&#39;event_offset&#39;</span><span class="p">]</span> <span class="o">-=</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;event_onset&#39;</span><span class="p">]</span>
                <span class="n">item</span><span class="p">[</span><span class="s1">&#39;event_onset&#39;</span><span class="p">]</span> <span class="o">-=</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;event_onset&#39;</span><span class="p">]</span>

                <span class="c1"># Only collect items which exists</span>
                <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])):</span>
                    <span class="n">train_meta</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>

            <span class="n">train_meta</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
                <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;train&#39;</span><span class="p">,</span>
                <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span>
                <span class="n">scene_label</span><span class="o">=</span><span class="s1">&#39;youtube&#39;</span><span class="p">,</span>
                <span class="n">file_extension</span><span class="o">=</span><span class="s1">&#39;txt&#39;</span><span class="p">)</span>
            <span class="p">)</span>

            <span class="n">evaluate_meta</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">MetaDataContainer</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span>
                    <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;groundtruth_strong_label_testing_set.csv&#39;</span><span class="p">)):</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s1">&#39;flac&#39;</span><span class="p">):</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;Y&#39;</span> <span class="o">+</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])[</span>
                        <span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">default_audio_extension</span><span class="p">)</span>
                <span class="c1"># Set scene label</span>
                <span class="n">item</span><span class="p">[</span><span class="s1">&#39;scene_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;youtube&#39;</span>

                <span class="c1"># Only collect items which exists</span>
                <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])):</span>
                    <span class="n">evaluate_meta</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>

            <span class="n">evaluate_meta</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
                <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;evaluate&#39;</span><span class="p">,</span>
                <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span>
                <span class="n">scene_label</span><span class="o">=</span><span class="s1">&#39;youtube&#39;</span><span class="p">,</span>
                <span class="n">file_extension</span><span class="o">=</span><span class="s1">&#39;txt&#39;</span><span class="p">)</span>
            <span class="p">)</span>

            <span class="n">test_meta</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">evaluate_meta</span><span class="p">:</span>
                <span class="n">test_meta</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">MetaDataItem</span><span class="p">({</span><span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]}))</span>

                <span class="n">test_meta</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
                    <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;test&#39;</span><span class="p">,</span>
                    <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span>
                    <span class="n">scene_label</span><span class="o">=</span><span class="s1">&#39;youtube&#39;</span><span class="p">,</span>
                    <span class="n">file_extension</span><span class="o">=</span><span class="s1">&#39;txt&#39;</span><span class="p">)</span>
                <span class="p">)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="n">fold</span> <span class="o">=</span> <span class="mi">1</span>
            <span class="n">meta_data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="n">meta_data</span> <span class="o">+=</span> <span class="n">MetaDataContainer</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
                <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;train&#39;</span><span class="p">,</span>
                <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span>
                <span class="n">scene_label</span><span class="o">=</span><span class="s1">&#39;youtube&#39;</span><span class="p">,</span>
                <span class="n">file_extension</span><span class="o">=</span><span class="s1">&#39;txt&#39;</span><span class="p">)</span>
            <span class="p">)</span>

            <span class="n">meta_data</span> <span class="o">+=</span> <span class="n">MetaDataContainer</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
                <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;evaluate&#39;</span><span class="p">,</span>
                <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span>
                <span class="n">scene_label</span><span class="o">=</span><span class="s1">&#39;youtube&#39;</span><span class="p">,</span>
                <span class="n">file_extension</span><span class="o">=</span><span class="s1">&#39;txt&#39;</span><span class="p">)</span>
            <span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">meta_data</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>


<span class="k">class</span> <span class="nc">DCASE2017_Task4tagging_EvaluationSet</span><span class="p">(</span><span class="n">DCASE2017_Task4tagging_DevelopmentSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;DCASE 2017 Large-scale weakly supervised sound event detection for smart cars</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;DCASE2017-task4-evaluation&#39;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DCASE2017_Task4tagging_DevelopmentSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">reference_data_present</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;audio tagging&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Benjamin Elizalde, Rohan Badlani, Ankit Shah, Emmanuel Vincent, Bhiksha Raj&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;Task 4 Large-scale weakly supervised sound event detection for smart cars&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="s1">&#39;https://github.com/ankitshah009/Task-4-Large-scale-weakly-supervised-sound-event-detection-for-smart-cars&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Field recording&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">1</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">default_audio_extension</span> <span class="o">=</span> <span class="s1">&#39;wav&#39;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://dl.dropboxusercontent.com/s/bbgqfd47cudwe9y/DCASE_2017_evaluation_set_audio_files.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;DCASE_2017_evaluation_set_audio_files.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">),</span>
                <span class="s1">&#39;zip_password&#39;</span><span class="p">:</span> <span class="s1">&#39;DCASE_2017_evaluation_set&#39;</span><span class="p">,</span>
            <span class="p">}</span>
        <span class="p">]</span>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">)):</span>
            <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">))</span>

        <span class="c1"># Get audio files at the root directory</span>
        <span class="n">audio_files</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">l</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">l</span><span class="p">:</span>
            <span class="n">file_name</span><span class="p">,</span> <span class="n">file_extension</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">file_extension</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">audio_extensions</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="n">f</span><span class="p">))</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">audio_files</span><span class="p">:</span>
                    <span class="n">audio_files</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="n">f</span><span class="p">)))</span>

        <span class="n">reference_data_file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;groundtruth_strong_label_evaluation_set.csv&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">reference_data_file</span><span class="p">):</span>
            <span class="c1"># Reference data is prensent and but meta data is empty</span>
            <span class="n">meta_data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="n">ref_data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">reference_data_file</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">ref_data</span><span class="p">:</span>
                <span class="c1"># Modify audio file path</span>
                <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s1">&#39;Y&#39;</span> <span class="o">+</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">default_audio_extension</span><span class="p">)</span>

                <span class="c1"># Set scene label</span>
                <span class="n">item</span><span class="p">[</span><span class="s1">&#39;scene_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;youtube&#39;</span>

                <span class="c1"># Only collect items which exists</span>
                <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])):</span>
                    <span class="n">meta_data</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
            <span class="c1"># Save meta data</span>
            <span class="n">meta_data</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span>

        <span class="c1"># Load meta data if present</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="k">return</span> <span class="p">[]</span>

    <span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">scene_label_</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>

                <span class="k">if</span> <span class="n">fold</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">audio_files</span><span class="p">:</span>
                        <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
                        <span class="n">relative_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">raw_path</span><span class="p">)</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">MetaDataItem</span><span class="p">({</span><span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">relative_path</span><span class="p">,</span> <span class="n">raw_filename</span><span class="p">)}))</span>

        <span class="k">if</span> <span class="n">scene_label</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="n">data</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span>

            <span class="k">return</span> <span class="n">data</span>

<span class="c1"># =====================================================</span>
<span class="c1"># DCASE 2016</span>
<span class="c1"># =====================================================</span>
<div class="viewcode-block" id="TUTAcousticScenes_2016_DevelopmentSet"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTAcousticScenes_2016_DevelopmentSet.html#dcase_framework.datasets.TUTAcousticScenes_2016_DevelopmentSet">[docs]</a><span class="k">class</span> <span class="nc">TUTAcousticScenes_2016_DevelopmentSet</span><span class="p">(</span><span class="n">AcousticSceneDataset</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;TUT Acoustic scenes 2016 development dataset</span>

<span class="sd">    This dataset is used in DCASE2016 - Task 1, Acoustic scene classification</span>

<span class="sd">    &quot;&quot;&quot;</span>

<div class="viewcode-block" id="TUTAcousticScenes_2016_DevelopmentSet.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTAcousticScenes_2016_DevelopmentSet.html#dcase_framework.datasets.TUTAcousticScenes_2016_DevelopmentSet.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-development&#39;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TUTAcousticScenes_2016_DevelopmentSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;acoustic scene&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Annamaria Mesaros, Toni Heittola, and Tuomas Virtanen&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;TUT Acoustic Scenes 2016, development dataset&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45739&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Field recording&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Roland Edirol R-09&#39;</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Soundman OKM II Klassik/studio A3 electret microphone&#39;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">4</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45739/files/TUT-acoustic-scenes-2016-development.doc.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-development.doc.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45739/files/TUT-acoustic-scenes-2016-development.meta.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-development.meta.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45739/files/TUT-acoustic-scenes-2016-development.error.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-development.error.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45739/files/TUT-acoustic-scenes-2016-development.audio.1.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-development.audio.1.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45739/files/TUT-acoustic-scenes-2016-development.audio.2.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-development.audio.2.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45739/files/TUT-acoustic-scenes-2016-development.audio.3.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-development.audio.3.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45739/files/TUT-acoustic-scenes-2016-development.audio.4.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-development.audio.4.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45739/files/TUT-acoustic-scenes-2016-development.audio.5.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-development.audio.5.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45739/files/TUT-acoustic-scenes-2016-development.audio.6.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-development.audio.6.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45739/files/TUT-acoustic-scenes-2016-development.audio.7.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-development.audio.7.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45739/files/TUT-acoustic-scenes-2016-development.audio.8.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-development.audio.8.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">}</span>
        <span class="p">]</span></div>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;After dataset packages are downloaded and extracted, meta-files are checked.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="n">meta_data</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">fold</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span><span class="p">):</span>
                <span class="c1"># Read train files in</span>
                <span class="n">fold_data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                    <span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;fold&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">fold</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_train.txt&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
                <span class="n">fold_data</span> <span class="o">+=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                    <span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;fold&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">fold</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_evaluate.txt&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">fold_data</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">meta_data</span><span class="p">:</span>
                        <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>
                        <span class="n">relative_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">raw_path</span><span class="p">)</span>
                        <span class="n">location_id</span> <span class="o">=</span> <span class="n">raw_filename</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                        <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">relative_path</span><span class="p">,</span> <span class="n">raw_filename</span><span class="p">)</span>
                        <span class="n">item</span><span class="p">[</span><span class="s1">&#39;identifier&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">location_id</span>
                        <span class="n">meta_data</span><span class="p">[</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]]</span> <span class="o">=</span> <span class="n">item</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">meta_data</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of training items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to training set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                    <span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;fold&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">fold</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_train.txt&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>
                    <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>
                    <span class="n">location_id</span> <span class="o">=</span> <span class="n">raw_filename</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;identifier&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">location_id</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span></div>


<div class="viewcode-block" id="TUTAcousticScenes_2016_EvaluationSet"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTAcousticScenes_2016_EvaluationSet.html#dcase_framework.datasets.TUTAcousticScenes_2016_EvaluationSet">[docs]</a><span class="k">class</span> <span class="nc">TUTAcousticScenes_2016_EvaluationSet</span><span class="p">(</span><span class="n">AcousticSceneDataset</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;TUT Acoustic scenes 2016 evaluation dataset</span>

<span class="sd">    This dataset is used in DCASE2016 - Task 1, Acoustic scene classification</span>

<span class="sd">    &quot;&quot;&quot;</span>
<div class="viewcode-block" id="TUTAcousticScenes_2016_EvaluationSet.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTAcousticScenes_2016_EvaluationSet.html#dcase_framework.datasets.TUTAcousticScenes_2016_EvaluationSet.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-evaluation&#39;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TUTAcousticScenes_2016_EvaluationSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;acoustic scene&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Annamaria Mesaros, Toni Heittola, and Tuomas Virtanen&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;TUT Acoustic Scenes 2016, evaluation dataset&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/165995&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Field recording&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Roland Edirol R-09&#39;</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Soundman OKM II Klassik/studio A3 electret microphone&#39;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">1</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/165995/files/TUT-acoustic-scenes-2016-evaluation.doc.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-evaluation.doc.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/165995/files/TUT-acoustic-scenes-2016-evaluation.audio.1.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-evaluation.audio.1.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/165995/files/TUT-acoustic-scenes-2016-evaluation.audio.2.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-evaluation.audio.2.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/165995/files/TUT-acoustic-scenes-2016-evaluation.audio.3.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-evaluation.audio.3.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/165995/files/TUT-acoustic-scenes-2016-evaluation.meta.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-acoustic-scenes-2016-evaluation.meta.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">}</span>
        <span class="p">]</span></div>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;After dataset packages are downloaded and extracted, meta-files are checked.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">eval_file</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;evaluate.txt&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span> <span class="ow">and</span> <span class="n">eval_file</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="n">eval_data</span> <span class="o">=</span> <span class="n">eval_file</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
            <span class="n">meta_data</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">eval_data</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">meta_data</span><span class="p">:</span>
                    <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>
                    <span class="n">relative_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">raw_path</span><span class="p">)</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">relative_path</span><span class="p">,</span> <span class="n">raw_filename</span><span class="p">)</span>
                    <span class="n">meta_data</span><span class="p">[</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]]</span> <span class="o">=</span> <span class="n">item</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">meta_data</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="k">return</span> <span class="p">[]</span>

    <span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of testing items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to testing set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;fold&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">fold</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_test.txt&#39;</span><span class="p">),</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">csv</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span><span class="p">):</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">row</span><span class="p">[</span><span class="mi">0</span><span class="p">])})</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">data</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="n">files</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">audio_files</span><span class="p">:</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">)</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">files</span><span class="p">:</span>
                        <span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">)})</span>
                        <span class="n">files</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">))</span>

                <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span></div>


<div class="viewcode-block" id="TUTSoundEvents_2016_DevelopmentSet"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTSoundEvents_2016_DevelopmentSet.html#dcase_framework.datasets.TUTSoundEvents_2016_DevelopmentSet">[docs]</a><span class="k">class</span> <span class="nc">TUTSoundEvents_2016_DevelopmentSet</span><span class="p">(</span><span class="n">SoundEventDataset</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;TUT Sound events 2016 development dataset</span>

<span class="sd">    This dataset is used in DCASE2016 - Task 3, Sound event detection in real life audio</span>

<span class="sd">    &quot;&quot;&quot;</span>

<div class="viewcode-block" id="TUTSoundEvents_2016_DevelopmentSet.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTSoundEvents_2016_DevelopmentSet.html#dcase_framework.datasets.TUTSoundEvents_2016_DevelopmentSet.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2016-development&#39;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TUTSoundEvents_2016_DevelopmentSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;sound event&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Annamaria Mesaros, Toni Heittola, and Tuomas Virtanen&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;TUT Sound Events 2016, development dataset&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45759&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Field recording&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Roland Edirol R-09&#39;</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Soundman OKM II Klassik/studio A3 electret microphone&#39;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">4</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;residential_area&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;home&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45759/files/TUT-sound-events-2016-development.doc.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2016-development.doc.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45759/files/TUT-sound-events-2016-development.meta.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2016-development.meta.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://zenodo.org/record/45759/files/TUT-sound-events-2016-development.audio.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2016-development.audio.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
        <span class="p">]</span></div>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;After dataset packages are downloaded and extracted, meta-files are checked.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="n">meta_data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">audio_files</span><span class="p">:</span>
                <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
                <span class="n">relative_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">raw_path</span><span class="p">)</span>
                <span class="n">scene_label</span> <span class="o">=</span> <span class="n">relative_path</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span>
                <span class="n">base_filename</span><span class="p">,</span> <span class="n">file_extension</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">raw_filename</span><span class="p">)</span>
                <span class="n">annotation_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                    <span class="n">relative_path</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;meta&#39;</span><span class="p">),</span>
                    <span class="n">base_filename</span> <span class="o">+</span> <span class="s1">&#39;.ann&#39;</span>
                <span class="p">)</span>

                <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">annotation_filename</span><span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">relative_path</span><span class="p">,</span> <span class="n">raw_filename</span><span class="p">)</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;scene_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">scene_label</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;identifier&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">raw_filename</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;source_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;mixture&#39;</span>

                <span class="n">meta_data</span> <span class="o">+=</span> <span class="n">data</span>
            <span class="n">meta_data</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;List of training items.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fold : int &gt; 0 [scalar]</span>
<span class="sd">            Fold id, if zero all meta data is returned.</span>
<span class="sd">            (Default value=0)</span>
<span class="sd">        scene_label : str</span>
<span class="sd">            Scene label</span>
<span class="sd">            Default value &quot;None&quot;</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        list : list of dicts</span>
<span class="sd">            List containing all meta data assigned to training set for given fold.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">scene_label_</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>

                <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
                        <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span>
                            <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;train&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label_</span><span class="p">))</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
                        <span class="n">scene_label</span><span class="o">=</span><span class="n">scene_label_</span>
                    <span class="p">)</span>

                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>
                    <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">])</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;identifier&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">raw_filename</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;source_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;mixture&#39;</span>

        <span class="k">if</span> <span class="n">scene_label</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="n">data</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_train</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span>

            <span class="k">return</span> <span class="n">data</span></div>


<div class="viewcode-block" id="TUTSoundEvents_2016_EvaluationSet"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTSoundEvents_2016_EvaluationSet.html#dcase_framework.datasets.TUTSoundEvents_2016_EvaluationSet">[docs]</a><span class="k">class</span> <span class="nc">TUTSoundEvents_2016_EvaluationSet</span><span class="p">(</span><span class="n">SoundEventDataset</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;TUT Sound events 2016 evaluation dataset</span>

<span class="sd">    This dataset is used in DCASE2016 - Task 3, Sound event detection in real life audio</span>

<span class="sd">    &quot;&quot;&quot;</span>
<div class="viewcode-block" id="TUTSoundEvents_2016_EvaluationSet.__init__"><a class="viewcode-back" href="../../generated/dcase_framework.datasets.TUTSoundEvents_2016_EvaluationSet.html#dcase_framework.datasets.TUTSoundEvents_2016_EvaluationSet.__init__">[docs]</a>    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2016-evaluation&#39;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TUTSoundEvents_2016_EvaluationSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;sound event&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Annamaria Mesaros, Toni Heittola, and Tuomas Virtanen&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;TUT Sound Events 2016, evaluation dataset&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="s1">&#39;http://www.cs.tut.fi/sgn/arg/dcase2016/download/&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Field recording&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Roland Edirol R-09&#39;</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Soundman OKM II Klassik/studio A3 electret microphone&#39;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">1</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;home&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;residential_area&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;http://www.cs.tut.fi/sgn/arg/dcase2016/evaluation_data/TUT-sound-events-2016-evaluation.doc.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2016-evaluation.doc.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;http://www.cs.tut.fi/sgn/arg/dcase2016/evaluation_data/TUT-sound-events-2016-evaluation.meta.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2016-evaluation.meta.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;http://www.cs.tut.fi/sgn/arg/dcase2016/evaluation_data/TUT-sound-events-2016-evaluation.audio.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-sound-events-2016-evaluation.audio.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>

        <span class="p">]</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">scene_labels</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">labels</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;home&#39;</span><span class="p">,</span> <span class="s1">&#39;residential_area&#39;</span><span class="p">]</span>
        <span class="n">labels</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">labels</span>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;After dataset packages are downloaded and extracted, meta-files are checked.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;meta&#39;</span><span class="p">)):</span>
            <span class="n">meta_file_handle</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;wt&#39;</span><span class="p">)</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">writer</span> <span class="o">=</span> <span class="n">csv</span><span class="o">.</span><span class="n">writer</span><span class="p">(</span><span class="n">meta_file_handle</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">audio_files</span><span class="p">:</span>
                    <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
                    <span class="n">relative_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">raw_path</span><span class="p">)</span>
                    <span class="n">scene_label</span> <span class="o">=</span> <span class="n">relative_path</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span>
                    <span class="n">base_filename</span><span class="p">,</span> <span class="n">file_extension</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">raw_filename</span><span class="p">)</span>

                    <span class="n">annotation_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                        <span class="n">relative_path</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;meta&#39;</span><span class="p">),</span>
                        <span class="n">base_filename</span> <span class="o">+</span> <span class="s1">&#39;.ann&#39;</span>
                    <span class="p">)</span>

                    <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">annotation_filename</span><span class="p">):</span>
                        <span class="n">annotation_file_handle</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">annotation_filename</span><span class="p">,</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span>
                        <span class="k">try</span><span class="p">:</span>
                            <span class="n">annotation_file_reader</span> <span class="o">=</span> <span class="n">csv</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">annotation_file_handle</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span><span class="p">)</span>
                            <span class="k">for</span> <span class="n">annotation_file_row</span> <span class="ow">in</span> <span class="n">annotation_file_reader</span><span class="p">:</span>
                                <span class="n">writer</span><span class="o">.</span><span class="n">writerow</span><span class="p">((</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">relative_path</span><span class="p">,</span> <span class="n">raw_filename</span><span class="p">),</span>
                                                 <span class="n">scene_label</span><span class="p">,</span>
                                                 <span class="nb">float</span><span class="p">(</span><span class="n">annotation_file_row</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;,&#39;</span><span class="p">,</span> <span class="s1">&#39;.&#39;</span><span class="p">)),</span>
                                                 <span class="nb">float</span><span class="p">(</span><span class="n">annotation_file_row</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;,&#39;</span><span class="p">,</span> <span class="s1">&#39;.&#39;</span><span class="p">)),</span>
                                                 <span class="n">annotation_file_row</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="s1">&#39;m&#39;</span><span class="p">))</span>
                        <span class="k">finally</span><span class="p">:</span>
                            <span class="n">annotation_file_handle</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
            <span class="k">finally</span><span class="p">:</span>
                <span class="n">meta_file_handle</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="k">return</span> <span class="p">[]</span>

    <span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">fold</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">scene_label_</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>

                <span class="k">if</span> <span class="n">fold</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="k">with</span> <span class="nb">open</span><span class="p">(</span>
                            <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="n">scene_label_</span> <span class="o">+</span> <span class="s1">&#39;_fold&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">fold</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_test.txt&#39;</span><span class="p">),</span>
                            <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>

                        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">csv</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span><span class="p">):</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                                <span class="p">{</span><span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">row</span><span class="p">[</span><span class="mi">0</span><span class="p">])}</span>
                            <span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="n">scene_label_</span> <span class="o">+</span> <span class="s1">&#39;_test.txt&#39;</span><span class="p">),</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">csv</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span><span class="p">):</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                                <span class="p">{</span><span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">row</span><span class="p">[</span><span class="mi">0</span><span class="p">])}</span>
                            <span class="p">)</span>

        <span class="k">if</span> <span class="n">scene_label</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">scene_label_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scene_labels</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_data_test</span><span class="p">[</span><span class="n">fold</span><span class="p">][</span><span class="n">scene_label_</span><span class="p">]:</span>
                    <span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
            <span class="k">return</span> <span class="n">data</span></div>


<span class="k">class</span> <span class="nc">CHiMEHome_DomesticAudioTag_DevelopmentSet</span><span class="p">(</span><span class="n">AudioTaggingDataset</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;CHiMeHome-audiotag-development&#39;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">CHiMEHome_DomesticAudioTag_DevelopmentSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;audio tagging&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Peter Foster, Siddharth Sigtia, Sacha Krstulovic, Jon Barker, and Mark Plumbley&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;The CHiME-Home dataset is a collection of annotated domestic environment audio recordings&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Field recording&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Natural&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Unknown&#39;</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Unknown&#39;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">5</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sample_mode</span> <span class="o">=</span> <span class="s1">&#39;.16kHz&#39;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;https://archive.org/download/chime-home/chime_home.tar.gz&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;chime_home.tar.gz&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;chime_home&#39;</span><span class="p">,</span> <span class="s1">&#39;chunks&#39;</span><span class="p">),</span>
            <span class="p">},</span>
        <span class="p">]</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">audio_files</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Get all audio files in the dataset, use only files from CHime-Home-refined set.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        files : list</span>
<span class="sd">            audio files</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">files</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">files</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span><span class="p">:</span>
                <span class="n">path</span> <span class="o">=</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;local_audio_path&#39;</span><span class="p">]</span>
                <span class="k">if</span> <span class="n">path</span><span class="p">:</span>
                    <span class="n">l</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
                    <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">l</span><span class="p">:</span>
                        <span class="n">file_name</span><span class="p">,</span> <span class="n">file_extension</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
                        <span class="k">if</span> <span class="n">file_extension</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">audio_extensions</span> <span class="ow">and</span> <span class="n">file_name</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sample_mode</span><span class="p">):</span>
                            <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">f</span><span class="p">))</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">files</span><span class="p">:</span>
                                <span class="bp">self</span><span class="o">.</span><span class="n">files</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">f</span><span class="p">)))</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">files</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">files</span>

    <span class="k">def</span> <span class="nf">read_chunk_meta</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">meta_filename</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">meta_filename</span><span class="p">):</span>
            <span class="n">meta_file_handle</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">meta_filename</span><span class="p">,</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">meta_file_reader</span> <span class="o">=</span> <span class="n">csv</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">meta_file_handle</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;,&#39;</span><span class="p">)</span>
                <span class="n">data</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="k">for</span> <span class="n">meta_file_row</span> <span class="ow">in</span> <span class="n">meta_file_reader</span><span class="p">:</span>
                    <span class="n">data</span><span class="p">[</span><span class="n">meta_file_row</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">meta_file_row</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
            <span class="k">finally</span><span class="p">:</span>
                <span class="n">meta_file_handle</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
            <span class="k">return</span> <span class="n">data</span>

    <span class="k">def</span> <span class="nf">read_file_list</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span>
        <span class="n">files</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">meta_data_handle</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;chime_home&#39;</span><span class="p">,</span> <span class="n">filename</span><span class="p">))</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">meta_file_reader</span> <span class="o">=</span> <span class="n">csv</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">meta_data_handle</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;,&#39;</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">meta_file_row</span> <span class="ow">in</span> <span class="n">meta_file_reader</span><span class="p">:</span>
                <span class="n">files</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">meta_file_row</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
        <span class="k">finally</span><span class="p">:</span>
            <span class="n">meta_data_handle</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">files</span>

    <span class="k">def</span> <span class="nf">tagcode_to_taglabel</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tag</span><span class="p">):</span>
        <span class="nb">map</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;c&#39;</span><span class="p">:</span> <span class="s1">&#39;child speech&#39;</span><span class="p">,</span>
               <span class="s1">&#39;m&#39;</span><span class="p">:</span> <span class="s1">&#39;adult male speech&#39;</span><span class="p">,</span>
               <span class="s1">&#39;f&#39;</span><span class="p">:</span> <span class="s1">&#39;adult female speech&#39;</span><span class="p">,</span>
               <span class="s1">&#39;v&#39;</span><span class="p">:</span> <span class="s1">&#39;video game/tv&#39;</span><span class="p">,</span>
               <span class="s1">&#39;p&#39;</span><span class="p">:</span> <span class="s1">&#39;percussive sound&#39;</span><span class="p">,</span>
               <span class="s1">&#39;b&#39;</span><span class="p">:</span> <span class="s1">&#39;broadband noise&#39;</span><span class="p">,</span>
               <span class="s1">&#39;o&#39;</span><span class="p">:</span> <span class="s1">&#39;other&#39;</span><span class="p">,</span>
               <span class="s1">&#39;S&#39;</span><span class="p">:</span> <span class="s1">&#39;silence/background&#39;</span><span class="p">,</span>
               <span class="s1">&#39;U&#39;</span><span class="p">:</span> <span class="s1">&#39;unidentifiable&#39;</span>
               <span class="p">}</span>
        <span class="k">if</span> <span class="n">tag</span> <span class="ow">in</span> <span class="nb">map</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">map</span><span class="p">[</span><span class="n">tag</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;After dataset packages are downloaded and extracted, meta-files are checked.</span>

<span class="sd">        Legacy dataset meta files are converted to be compatible with current scheme.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="n">scene_label</span> <span class="o">=</span> <span class="s1">&#39;home&#39;</span>

            <span class="n">files</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">read_file_list</span><span class="p">(</span><span class="s1">&#39;development_chunks_refined.csv&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">read_file_list</span><span class="p">(</span><span class="s1">&#39;evaluation_chunks_refined.csv&#39;</span><span class="p">)</span>
            <span class="n">meta</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">audio_files</span><span class="p">:</span>
                <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
                <span class="n">relative_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">raw_path</span><span class="p">)</span>

                <span class="n">base_filename</span><span class="p">,</span> <span class="n">file_extension</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">raw_filename</span><span class="p">)</span>
                <span class="n">annotation_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">raw_path</span><span class="p">,</span> <span class="n">base_filename</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sample_mode</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;.csv&#39;</span><span class="p">)</span>
                <span class="n">meta_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">read_chunk_meta</span><span class="p">(</span><span class="n">annotation_filename</span><span class="p">)</span>
                <span class="n">tags</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">tag</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">meta_data</span><span class="p">[</span><span class="s1">&#39;majorityvote&#39;</span><span class="p">]):</span>
                    <span class="k">if</span> <span class="n">tag</span> <span class="ow">is</span> <span class="s1">&#39;b&#39;</span><span class="p">:</span>
                        <span class="nb">print</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>

                    <span class="k">if</span> <span class="n">tag</span> <span class="ow">is</span> <span class="ow">not</span> <span class="s1">&#39;S&#39;</span> <span class="ow">and</span> <span class="n">tag</span> <span class="ow">is</span> <span class="ow">not</span> <span class="s1">&#39;U&#39;</span><span class="p">:</span>
                        <span class="n">tags</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tagcode_to_taglabel</span><span class="p">(</span><span class="n">tag</span><span class="p">))</span>

                <span class="n">meta</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                    <span class="n">MetaDataItem</span><span class="p">({</span>
                        <span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">relative_path</span><span class="p">,</span> <span class="n">raw_filename</span><span class="p">),</span>
                        <span class="s1">&#39;scene_label&#39;</span><span class="p">:</span> <span class="n">scene_label</span><span class="p">,</span>
                        <span class="s1">&#39;tags&#39;</span><span class="p">:</span> <span class="s1">&#39;;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">tags</span><span class="p">)</span><span class="o">+</span><span class="s1">&#39;;&#39;</span><span class="p">,</span>
                    <span class="p">})</span>
                <span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">meta</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

        <span class="n">all_folds_found</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">for</span> <span class="n">fold</span> <span class="ow">in</span> <span class="n">xrange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span><span class="p">):</span>
            <span class="n">train_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span>
                                          <span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span><span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;train&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">))</span>
            <span class="n">test_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span>
                                         <span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span><span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;test&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">))</span>

            <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">train_filename</span><span class="p">):</span>
                <span class="n">all_folds_found</span> <span class="o">=</span> <span class="kc">False</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">test_filename</span><span class="p">):</span>
                <span class="n">all_folds_found</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">all_folds_found</span><span class="p">:</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">):</span>
                <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">)</span>

            <span class="n">dcase_crossval</span> <span class="o">=</span> <span class="p">{</span>
                <span class="mi">1</span><span class="p">:</span> <span class="p">[],</span>
                <span class="mi">2</span><span class="p">:</span> <span class="p">[],</span>
                <span class="mi">3</span><span class="p">:</span> <span class="p">[],</span>
                <span class="mi">4</span><span class="p">:</span> <span class="p">[],</span>
                <span class="mi">5</span><span class="p">:</span> <span class="p">[],</span>
            <span class="p">}</span>
            <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;chime_home&#39;</span><span class="p">,</span> <span class="s1">&#39;development_chunks_refined_crossval_dcase2016.csv&#39;</span><span class="p">),</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">csv</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;,&#39;</span><span class="p">):</span>
                    <span class="n">dcase_crossval</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">row</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span><span class="o">+</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span>
                            <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s1">&#39;chime_home&#39;</span><span class="p">,</span> <span class="s1">&#39;chunks&#39;</span><span class="p">,</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">sample_mode</span> <span class="o">+</span> <span class="s1">&#39;.wav&#39;</span><span class="p">)</span>
                        <span class="p">)</span>
                    <span class="p">)</span>

            <span class="k">for</span> <span class="n">fold</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span><span class="o">+</span><span class="mi">1</span><span class="p">):</span>
                <span class="c1"># Collect training and testing files</span>
                <span class="n">train_files</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span><span class="o">+</span><span class="mi">1</span><span class="p">):</span>
                    <span class="k">if</span> <span class="n">f</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">fold</span><span class="p">:</span>
                        <span class="n">train_files</span> <span class="o">+=</span> <span class="n">dcase_crossval</span><span class="p">[</span><span class="n">f</span><span class="p">]</span>
                <span class="n">test_files</span> <span class="o">=</span> <span class="n">dcase_crossval</span><span class="p">[</span><span class="n">fold</span><span class="p">]</span>

                <span class="c1"># Create meta containers and save them</span>

                <span class="c1"># Train</span>
                <span class="n">train_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span>
                                              <span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span><span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;train&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">))</span>

                <span class="n">train_meta</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">train_filename</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="n">train_files</span><span class="p">:</span>
                    <span class="n">train_meta</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">file_meta</span><span class="p">(</span><span class="n">filename</span><span class="p">)[</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">train_meta</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>

                <span class="c1"># Test</span>
                <span class="n">test_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span>
                                             <span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span><span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;test&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">))</span>
                <span class="n">test_meta</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">test_filename</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="n">test_files</span><span class="p">:</span>
                    <span class="n">test_meta</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">MetaDataItem</span><span class="p">({</span><span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">filename</span><span class="p">)}))</span>
                <span class="n">test_meta</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>

                <span class="c1"># Evaluate</span>
                <span class="n">eval_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span>
                                             <span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span><span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;evaluate&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">))</span>
                <span class="n">eval_meta</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">eval_filename</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="n">test_files</span><span class="p">:</span>
                    <span class="n">eval_meta</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">file_meta</span><span class="p">(</span><span class="n">filename</span><span class="p">)[</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">eval_meta</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>

<span class="c1"># =====================================================</span>
<span class="c1"># Others</span>
<span class="c1"># =====================================================</span>
<span class="k">class</span> <span class="nc">TUT_SED_Synthetic_2016</span><span class="p">(</span><span class="n">SoundEventDataset</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;TUT SED Synthetic 2016</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;storage_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;storage_name&#39;</span><span class="p">,</span> <span class="s1">&#39;TUT-SED-synthetic-2016&#39;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TUT_SED_Synthetic_2016</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_group</span> <span class="o">=</span> <span class="s1">&#39;sound event&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dataset_meta</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;authors&#39;</span><span class="p">:</span> <span class="s1">&#39;Emre Cakir&#39;</span><span class="p">,</span>
            <span class="s1">&#39;name_remote&#39;</span><span class="p">:</span> <span class="s1">&#39;TUT-SED Synthetic 2016&#39;</span><span class="p">,</span>
            <span class="s1">&#39;url&#39;</span><span class="p">:</span> <span class="s1">&#39;http://www.cs.tut.fi/sgn/arg/taslp2017-crnn-sed/tut-sed-synthetic-2016&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_source&#39;</span><span class="p">:</span> <span class="s1">&#39;Field recording&#39;</span><span class="p">,</span>
            <span class="s1">&#39;audio_type&#39;</span><span class="p">:</span> <span class="s1">&#39;Synthetic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;recording_device_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Unknown&#39;</span><span class="p">,</span>
            <span class="s1">&#39;microphone_model&#39;</span><span class="p">:</span> <span class="s1">&#39;Unknown&#39;</span><span class="p">,</span>
        <span class="p">}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">crossvalidation_folds</span> <span class="o">=</span> <span class="mi">1</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">package_list</span> <span class="o">=</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;http://www.cs.tut.fi/sgn/arg/taslp2017-crnn-sed/datasets/TUT-SED-synthetic-2016/TUT-SED-synthetic-2016.audio.1.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-SED-synthetic-2016.audio.1.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;http://www.cs.tut.fi/sgn/arg/taslp2017-crnn-sed/datasets/TUT-SED-synthetic-2016/TUT-SED-synthetic-2016.audio.2.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-SED-synthetic-2016.audio.2.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;http://www.cs.tut.fi/sgn/arg/taslp2017-crnn-sed/datasets/TUT-SED-synthetic-2016/TUT-SED-synthetic-2016.audio.3.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-SED-synthetic-2016.audio.3.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;http://www.cs.tut.fi/sgn/arg/taslp2017-crnn-sed/datasets/TUT-SED-synthetic-2016/TUT-SED-synthetic-2016.audio.4.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-SED-synthetic-2016.audio.4.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;http://www.cs.tut.fi/sgn/arg/taslp2017-crnn-sed/datasets/TUT-SED-synthetic-2016/TUT-SED-synthetic-2016.audio.5.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-SED-synthetic-2016.audio.5.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
            <span class="p">{</span>
                <span class="s1">&#39;remote_package&#39;</span><span class="p">:</span> <span class="s1">&#39;http://www.cs.tut.fi/sgn/arg/taslp2017-crnn-sed/datasets/TUT-SED-synthetic-2016/TUT-SED-synthetic-2016.meta.zip&#39;</span><span class="p">,</span>
                <span class="s1">&#39;local_package&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;TUT-SED-synthetic-2016.meta.zip&#39;</span><span class="p">),</span>
                <span class="s1">&#39;local_audio_path&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span> <span class="s1">&#39;audio&#39;</span><span class="p">),</span>
            <span class="p">},</span>
        <span class="p">]</span>

    <span class="k">def</span> <span class="nf">_after_extract</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_return</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;After dataset packages are downloaded and extracted, meta-files are checked.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        nothing</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        nothing</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="n">meta_data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">audio_files</span><span class="p">:</span>
                <span class="n">raw_path</span><span class="p">,</span> <span class="n">raw_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>

                <span class="n">relative_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absolute_to_relative</span><span class="p">(</span><span class="n">raw_path</span><span class="p">)</span>
                <span class="n">base_filename</span><span class="p">,</span> <span class="n">file_extension</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">raw_filename</span><span class="p">)</span>
                <span class="n">annotation_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">local_path</span><span class="p">,</span>
                    <span class="n">relative_path</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;audio&#39;</span><span class="p">,</span> <span class="s1">&#39;meta&#39;</span><span class="p">),</span>
                    <span class="n">base_filename</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;-mix-&#39;</span><span class="p">,</span> <span class="s1">&#39;-annot-&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;.txt&#39;</span>
                <span class="p">)</span>

                <span class="n">data</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">annotation_filename</span><span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">relative_path</span><span class="p">,</span> <span class="n">raw_filename</span><span class="p">)</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;scene_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;synthetic&#39;</span>
                    <span class="n">item</span><span class="p">[</span><span class="s1">&#39;source_label&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;mixture&#39;</span>

                <span class="n">meta_data</span> <span class="o">+=</span> <span class="n">data</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">meta_data</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">meta_container</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">_get_evaluation_setup_filename</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;train&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">file_extension</span><span class="o">=</span><span class="s1">&#39;txt&#39;</span><span class="p">):</span>
        <span class="n">parts</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="n">scene_label</span><span class="p">:</span>
            <span class="n">parts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">scene_label</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">fold</span><span class="p">:</span>
            <span class="n">parts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;fold&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">fold</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">setup_part</span> <span class="o">==</span> <span class="s1">&#39;train&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;train+validate&#39;</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="n">file_extension</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">setup_part</span> <span class="o">==</span> <span class="s1">&#39;test&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;test&#39;</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="n">file_extension</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">setup_part</span> <span class="o">==</span> <span class="s1">&#39;validate&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;validate&#39;</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="n">file_extension</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">setup_part</span> <span class="o">==</span> <span class="s1">&#39;evaluate&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">evaluation_setup_path</span><span class="p">,</span> <span class="s1">&#39;evaluate&#39;</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="n">file_extension</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">validation_files</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">scene_label</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="n">validation_files</span> <span class="o">=</span> <span class="n">MetaDataContainer</span><span class="p">(</span>
            <span class="n">filename</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_evaluation_setup_filename</span><span class="p">(</span><span class="n">setup_part</span><span class="o">=</span><span class="s1">&#39;validate&#39;</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">)</span>
        <span class="p">)</span><span class="o">.</span><span class="n">load</span><span class="p">()</span><span class="o">.</span><span class="n">file_list</span>

        <span class="k">for</span> <span class="n">index</span><span class="p">,</span> <span class="n">filename</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">validation_files</span><span class="p">):</span>
            <span class="n">validation_files</span><span class="p">[</span><span class="n">index</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">relative_to_absolute_path</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">validation_files</span>

</pre></div>

           </div>
           <div class="articleComments">
            
           </div>
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2017, Toni Heittola et al..

    </p>
  </div> 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../../',
            VERSION:'1.0',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true,
            SOURCELINK_SUFFIX: '.txt'
        };
    </script>
      <script type="text/javascript" src="../../_static/jquery.js"></script>
      <script type="text/javascript" src="../../_static/underscore.js"></script>
      <script type="text/javascript" src="../../_static/doctools.js"></script>

  

  
  
    <script type="text/javascript" src="../../_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>